pm0@beach.cis.ufl.edu (Patrick Martin) (10/08/90)
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@beach.cis.ufl.edu)
henry@zoo.toronto.edu (Henry Spencer) (10/08/90)
In article <24751@uflorida.cis.ufl.EDU> pm0@beach.cis.ufl.edu () writes: >Is there any easy way to get it to scan for 1 character only without using >special libraries like curses.h to achieve this? No. I believe the frequently-asked-questions posting has some detail on this. -- Imagine life with OS/360 the standard | Henry Spencer at U of Toronto Zoology operating system. Now think about X. | henry@zoo.toronto.edu utzoo!henry
jh4o+@andrew.cmu.edu (Jeffrey T. Hutzelman) (10/08/90)
No. Depending on the operating system you are using, there might be a
way; ask on the appropriate newsgroup for that OS. Sorry.
-----------------
Jeffrey Hutzelman
America Online: JeffreyH11
Internet/BITNET:jh4o+@andrew.cmu.edu, jhutz@drycas.club.cc.cmu.edu
>> Apple // Forever!!! <<
pm0@beach.cis.ufl.edu (Patrick Martin) (10/08/90)
Thanks for the information. I meant to say printf("Char = %c %d",ch,ch); instead of erroneously saying printf("Char = %c %d"); Sorry about the confusion. Pat
eyal@echo.canberra.edu.au (Eyal Lebedinsky) (10/08/90)
In article <24751@uflorida.cis.ufl.EDU> pm0@beach.cis.ufl.edu () writes: >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? > On Unix, set the tty to raw mode. In msdos use getch/getche to do raw read. >Thanks in advance, > >Pat (pm0@beach.cis.ufl.edu) -- Regards Eyal