Validating data on key pressing.

Questions about programming languages and debugging
Post Reply
User avatar
z3r0aCc3Ss
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 700
Joined: 23 Jun 2009, 16:00
14
Contact:

Validating data on key pressing.

Post by z3r0aCc3Ss »

Is there any way by which I can validate the data on pressing a key?
For example,
int n;
I want only numbers to go in this. When I press "a" or "s", alphabets should not even appear on the screen. Only integer data should appear. It can be done using ASCII codes.
In VB, we do it by using keyAscii. What's the way in C++?
Please provide a sample code...
Beta tester for major RATs, all kinds of stealers and keyloggers.
Learning NMAP

User avatar
ayu
Staff
Staff
Posts: 8109
Joined: 27 Aug 2005, 16:00
18
Contact:

Re: Validating data on key pressing.

Post by ayu »

well one way you can do it is to use isdigit() to check if it's a character or a valid decimal digit.

Code: Select all

http://www.cplusplus.com/reference/clibrary/cctype/isdigit/
"The best place to hide a tree, is in a forest"

Post Reply