473,499 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

getch() and ungetch() ?

15 New Member
when i use getch , then it reads the data from the keyboard but it does not display it on screen as in the case of getchar(). So should i use ungetch() or some thing else.
but the program executes well and give output other then the current entered data from the keyboard.
Plz help

Regard
cworld.
Jan 19 '07 #1
2 4031
horace1
1,510 Recognized Expert Top Contributor
when i use getch , then it reads the data from the keyboard but it does not display it on screen as in the case of getchar(). So should i use ungetch() or some thing else.
but the program executes well and give output other then the current entered data from the keyboard.
Plz help

Regard
cworld.
Text streams in C operate on a line by line basis with characters entered being placed in an input buffer until newline (or end of file) is entered. The next character can then be read by getchar (or scanf) and passed to the program.

Some C systems have functions which will read individual characters directly from the keyboard, e.g. MicroSoft C and Borland Turbo C have functions getche (echo character) and getch (no echo) in <conio.h>. It is recommended that you don't use getch() or getche() if you wish your code to be portable.
Jan 19 '07 #2
cworld
15 New Member
Text streams in C operate on a line by line basis with characters entered being placed in an input buffer until newline (or end of file) is entered. The next character can then be read by getchar (or scanf) and passed to the program.

Some C systems have functions which will read individual characters directly from the keyboard, e.g. MicroSoft C and Borland Turbo C have functions getche (echo character) and getch (no echo) in <conio.h>. It is recommended that you don't use getch() or getche() if you wish your code to be portable.
Thankyou so much horace!
now i understand the concept of getch() and getchar very well
Thanx once again

Regards
cworld
Jan 20 '07 #3

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

Similar topics

3
5346
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...
15
3713
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
11596
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...
1
21634
by: Ratheesh Kumar | last post by:
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...
45
3296
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
5220
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
5606
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...
3
5938
by: kalar | last post by:
I can't understand how ungetch works. I read an explanation on kernighan and ritchie book but i can't understand.Can anyone give me a simple example?? Also, should i include any header file expect...
16
3420
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
7169
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,...
1
6892
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7385
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5467
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4917
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4597
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3096
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3088
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1425
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.