- #1
Peter P.
- 23
- 0
im looking for functions that do not require the user to press enter. such as, they press "a" and the program continues, instead of something like "a[enter]" when using scanf.
If you only plan to run those programs in windows dos console mode (or an actual copy of MSDOS, either dual boot or virtual pc), then conio is fine.Peter P. said:Also, i was looking through the non-standard libraries that the compiler i use has, and noticed conio.h, i was wondering whether it would be better to just stick with conio or use curses?
In C programming, you can use the getch()
function from the conio.h
library to get user input without requiring the Enter key. This function reads a single character from the keyboard without waiting for the user to press Enter.
Yes, it is possible to get multiple characters as input without using the Enter key in C programming. You can use the getch()
function in a loop to continuously read characters until the desired input length is reached.
To clear the input buffer in C programming, you can use the fflush(stdin)
command. This command flushes any remaining characters in the input buffer, allowing you to start fresh with new user input.
Yes, you can get numerical input without using the Enter key in C programming. You can use the getch()
function to read individual characters and then use the atoi()
or atof()
functions to convert them into numerical values.
getch()
function for getting input without the Enter key in C programming?One limitation of using the getch()
function is that it only reads a single character at a time. This can be inefficient for getting large amounts of user input. Additionally, the conio.h
library is not supported by all C compilers, so this method may not be portable across different systems.