silvert@dalcs.UUCP (Bill Silvert) (06/06/86)
I've run into problems writing a function to return a single character from the console -- a raw version of getchar(). It sounds simple, but what I've done works erratically. Problem is, most of the input is standard line-oriented gets, but for some program parts it would be nice to skip the RETURN after input. I need to reset the necessary termio flags (this is version V), and it seems that read(0, &char, 1) should then give me the character I need. Problem is, that after about 20 calls the program hangs. The number of calls before the hang is not exactly reproducible. I assume that this is associated with the read(...), but do not know what to do about it. I've looked at some examples in texts and looked over code that does raw I/O, but the former got me into this problem and the latter tend to be pretty massive blocks of code. If anyone has a working routine, I would appreciate it -- remember that raw input is the exception for this program, so the function has to set and reset the termio flags for each call.