PDA

View Full Version : Checking if <Enter> key is pressed.


odinzu
11-07-2007, 04:28 AM
I am writing a program and I need to check if the user enters something in or if he just enter it will give a default path for a file.

I tried \0 and \n...It never worked correctly. How would I exactly compare or check if the user has just hit the enter key.

As of now, I the enter key and all it does is goto the next line waiting for the correct input from the user.

Active X
11-07-2007, 10:29 AM
Hi odinzu ,

whatever thing you need to do is to use getch() function in conio.h header file .

use it this way : (while you've included conio.h)


if (getch() == "A")
{
}


or for enter key : (You must use Integer casting (int) )


if ((int)getch() == 13)
{
// ...
}



I wish I have provided you enough information .


God loves you and will never love you less !

odinzu
11-08-2007, 12:22 AM
Thanks man. Appreciate the help!

Active X
11-08-2007, 10:19 AM
You're welcome