0

Hello,

Is there a function that would allow me to check the characters when they key is pressed....before the enter key?

I am coding a program that requieres the user to enter only letters (from A to Z && a to z), but I want to check each character when it's being entered.

4
Contributors
7
Replies
8
Views
11 Years
Discussion Span
Last Post by red
0

There's no standard way (C and C++ are line oriented), so you'll need to tell us your compiler and operating system.

0

Yes, but you can't do them portably. If you are using borland or visual C++ compilers you can try the getch() or getche() function to do that.

0

Whoa! you guys are fast, one minute ago there were no reply and now two posts in between the red's first and mine.

To red:
I can use getch() or getche() in gcc that comes with MinGW, so you should be able to do that in Dev C++ too.

0

Thanks to both of you,

What library do I need to include for the getch() and getche() functions? I tried them both but the compiler is telling me that those functions are not defined. All I am including is the <iostream>.

0

Those are non-standard C functions that are defined in conio.h. Because they are non-standard, they may not be supported by all compilers (I think Dev-C++ supports them)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.