Erik Mouw
Sun Feb 20 10:07:00 GMT 2000

On Sun, 20 Feb 2000 15:53:54 +0000, Joachim wrote:
> I'm very new with gcc so please forgive me my stupid question!
> I was wondering if there would be a function available that reads only
> one character from stdin.
> To be more specific I need something that works the same way as:
> kbhit() or...
> getch() or...
> getche() alias Borlands <conio.h>
> I need it to write an input function to handle my own keyboard
> definitions. 
> Unfortunatly getchar() is unsuitablee for what I want to do. 
> Any glues on what to use?

First of all, this is not the correct mailing list. This list about the
development of gcc, not the development with gcc. If you're working on
Linux, consider joining the Linux-C-Programming mailinglist:

To answer your question: all functions in conio.h are DOS specific (as the
Borland manuals will point out). Your problem is that you are using the
stdin FILE pointer which is buffered, so all read functions won't return
until the complete line is read. Make it unbuffered (man setbuf). You can
also use the S-Lang library, which makes it as simple as using the
function SLang_getkey(). The book "Linux Application Development" by
Michael K. Johnson and Erik W. Troan has a complete chapter about S-Lang.


J.A.K. (Erik) Mouw, Information and Communication Theory Group, Department
of Electrical Engineering, Faculty of Information Technology and Systems,
Delft University of Technology, PO BOX 5031,  2600 GA Delft, The Netherlands
Phone: +31-15-2785859  Fax: +31-15-2781843  Email

More information about the Gcc mailing list