Darn enter key...
How can I make an input stream (e.g. getchar, fgets, scanf) do its thing or enter its input without having to push enter? like say i have a menu, with some options, eg (a)dd, (h)elp, i would like it to to add or go to help immediatly after pushing a or h, without having to push enter...do you understand? i hope...
Im using gcc 2.9x on linux.
If you have Borlands conio.h, you can:
char Key = 0;
while(Key != 'q')
Key = 0;
if(kbhit()) Key = getch();
if(Key == 'a')
gcc also has the same (or very similar, i dunno, check your man pages) conio kbhit() functionality
If you read my post, I said I used linux, so how htne could i be using borland? thanks for your answer anyway... and I also do not want to use conio.h, itīs non stanfdard. any other solutions?
great, google must be down or something...
i dont have conio on my linux box, thatīs why im asking for an alternative, because surely there must be one...
[highshool teacher quote]
[/highschool teacher quote]
>>>and I also do not want to use conio.h, itīs non stanfdard. any other solutions?
There is no standard C way to do what you ask.
oh, that sucks...
can I use the conio.h that comes with libsdl and just throw it into
/usr/include? will that work? if not, do you have any suggestions as to wherei can obtain a conio header?
>i dont have conio on my linux box, thatīs why im asking for an alternative, because surely there must be one...
You can fake it with Linux terminal commands, the simplest being:
system ( "stty raw" );
ch = getchar();
system ( "stty cooked" );