Getch () waiting for Enter key?

Possible duplicate:
C / C ++: capture characters from standard input without waiting for a keystroke

I am using C-Free 4 Standard for Windows 7 and I am writing a C program.

I use getch () as a function to pause the program, however the character pressed an echo on the screen and it waits for the Enter key to be pressed before moving on (it does not look different from how scanf works). I tried getche () and it works fine, although an echo appears.

What could be the problem with getch () function?

+4
source share
2 answers

The receiver, wgetch, mvgetch and mvwgetch, routines read the character from the window. In non-delay mode, if the input is not located, the ERR value is returned. In the delay mode, the program waits while the system transfers the text to the program. Depending on the cbreak, this is after one character (cbreak mode), or after the first newline (nocbreak mode). In half-delay mode, the program waits while a character is typed or a specified timeout is made.

More or less the same method is used on Windows. You can use _getch () to get the input character for an application without buffering.

+2
source

In fact, there are several ways to do pause execution of your program until you type something, one way to do it is with getchar () (which is part of the stdio.h function set and the official standard library), it will do the same effect. as getch() (this function is part of the conio.h function set, which is not an official library).

If your problem is that you want to avoid pressing Enter every time you type a character that is not very clear in your question), read the following: To avoid printing, enter with any getchar ()

0
source

All Articles