473,386 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 21626
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

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

Similar topics

3
by: voidstar | last post by:
Hi, I have the following problem: I use "getch" to monitor keypresses and the I use "cin" to input a string. When I type in 'y', the 'y' character appears, so I need to hit backspace before...
2
by: Shugong Wang | last post by:
getch() function is not a standard C/C++ function. Thought gcc provieds ncurses.h and a getch() function is realized, I still want to know how to realize a getch() function in standard c or c++.
4
by: aurgathor | last post by:
Howdy, What would be the equivalent of getch() using iostream? My current code is: cout << "\nPress <Enter> to continue..."; getch(); but <conio.h> is not kosher for the C++ class.
15
by: Profetas | last post by:
Hi, How do I read a char from stdin before the '\n' is pressed? for example I know that I can use getch() to read a single char from the user input, but suppose I wanted to read before the...
4
by: Crow | last post by:
Is there any way to make cin behave like getch()? Specifically, getch() returns immediately after a key is pressed and the cin family of input methods seem to block until a new line is...
45
by: simnav | last post by:
In the following code something strange happens ! If I keep pressed any of ALT+Arrow, keys, they are extracted two times from buffer then getch seems to stop; if I release and press again ALT+arrow...
5
by: Sankar | last post by:
Dear all, In my programming snippet compiled in Linux 2.6, I have a getch() , but the program when executed does not wait for my input.. fflush(stdin), fflush(stdout) - All these did not help. ...
8
by: Michele 'xjp' | last post by:
Hi there, I am using a POSIX-compliant system, Cygwin on Windows. I need the features of conio.h's getch() and clrscr(), but I can't compile programs with #include <conio.h(since conio.h is NOT...
16
by: fuzhen | last post by:
If I want to "press any key to continue" in Windows, I can use getch() But the getch() isn't a standard C function So what should I to do in Linux?
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.