468,512 Members | 1,337 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,512 developers. It's quick & easy.

how getch()?

My doubt is on the working of getch() function based on the following observations
1) if the pressed key has an ascii code,only that can be read using a single call to getch()
2) if the key has not an ascii code then the first call to getch() returns a zero and ,if we made a second call, it will return the scan code with out an additional key press.
Some one please help me to understand getch()
Sep 6 '06 #1
1 21329
Hellow Rathish Kumar,
Please follow the following,
Alphabets, Numbers are have ascii value and scan value. But, Arrow keys, Ctrl, Shift, Function Keys are have only scan value.

For Example,
int a;
a = getch();
if(a == 0)
a = getch();

If you press numbers or alphabets, then ascii values is stored in the variable a.
But you pressed esc or enter or arrow keys, then that keys are not have ascii value(only scan value). so, system will automatically gets scan value and stored it in to the variable a(With out using another time reading input from user).

Regards,
Suresh
Sep 6 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by voidstar | last post: by
2 posts views Thread by Shugong Wang | last post: by
4 posts views Thread by aurgathor | last post: by
15 posts views Thread by Profetas | last post: by
4 posts views Thread by Crow | last post: by
45 posts views Thread by simnav | last post: by
5 posts views Thread by Sankar | last post: by
8 posts views Thread by Michele 'xjp' | last post: by
16 posts views Thread by fuzhen | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.