C Programming: Getting Input Without Enter Key

  • Thread starter Thread starter Peter P.
  • Start date Start date
  • Tags Tags
    Input
AI Thread Summary
The discussion centers on the need for functions in C programming that allow user input without requiring the Enter key, specifically through the use of libraries. Standard C does not support this functionality, but system-dependent libraries like Curses can be utilized. The getch() function from Curses allows for immediate input detection. However, proper initialization and termination of the library are crucial to avoid issues with keyboard input after program termination. Users also consider the conio.h library, which is suitable for Windows DOS console applications. For those using the Pelles C compiler on Windows 7, conio.h may be sufficient if the programs are intended for that environment, while Curses offers more flexibility for cross-platform applications. Guidance on setting up Curses is requested, indicating a need for clear instructions for users unfamiliar with the library.
Peter P.
Messages
23
Reaction score
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.
 
Technology news on Phys.org
You can't do this in standard C.

You can do it using system-dependent libraries. One that is fairly widely available (but with minor differences on different operating systems) is http://en.wikipedia.org/wiki/Curses_(programming_library ). The function you want is getch(), but you need to read a tutorial to find out how to initialize and terminate using the library properly. (Otherwise, in the worst case, when your program terminates NOTHING will be able to read the keyboard again until you reboot the computer!)
 
Last edited by a moderator:
Thanks for the reply.

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? and if anyone would suggest curses, can you possibly tell me how to set it up? i use pelles c compiler and my laptop is running windows 7.
 
Last edited:
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?
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.
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
Back
Top