Getkey type function

Patrick Martin pm0 at beach.cis.ufl.edu
Mon Oct 8 03:01:54 AEST 1990


How can one just scan the keyboard for 1 and only 1 character?  I need a
function similar to the getkey or $inkey function in basic.

I do something like this:

char ch

while ((ch = getchar()) != 'q') {
   printf("Char = %c %d");
   do_whatever();
}

This evaluates the character I input and also the return character because
Char = 10 is printed out after the inputted char is printed out.

Is there any easy way to get it to scan for 1 character only without using
special libraries like curses.h to achieve this?

Thanks in advance,

Pat (pm0 at beach.cis.ufl.edu)



More information about the Comp.lang.c mailing list