Click to See Complete Forum and Search --> : reading chars as they come (C question)


Adrian Papari
10-19-2001, 01:22 AM
hello,

being a newbie c-programmer i'm having a hard time figuring out how to read a character at a time when dealing with keyboard input.
in the c-tutorials i've been reading, this is supposed to be achieved by using the conio.h api. from what i've gathered conio.h is a dos/win-specific library, if not, where can i get it?

thnx in adv.
//adrian papari

jemfinch
10-19-2001, 02:06 AM
Check out getc(3).

Jeremy

kmj
10-19-2001, 10:20 AM
if you're new to linux, that means run man 3 getc

sans-hubris
10-19-2001, 12:25 PM
Many of the things that conio.h does can be done with curses, but curses does a much cleaner implementation. Curses can be complex though, so for now, just use getc().

[ 19 October 2001: Message edited by: Muad Dib --formerly ndogg ]

jkm
10-19-2001, 02:29 PM
A better solution, probably slightly more complex for a beginner, but a less bloated one, would be to flip terminal settings around to turn off blocked input.

man 3 termios, should provide alot of help.

I believe, www.codeexamples.org (http://www.codeexamples.org) also has an implementation.

Adrian Papari
10-19-2001, 02:41 PM
thnx for the answers... well i haven't had the time to play around with the getc() and all that just yet.

as for the src-file at www.codeexamples.org (http://www.codeexamples.org) - i t lacked some useful comments... a lot of the code was copied from 'top's source i believe.

i suppose i'll have to find some money and buy myself a c-reference book and a 'thinking-in-c-book'.

cheers