This is a discussion that's been going on on another board that I visit every now and again.
Now I'll admit the only code I've ever worked with on a *nix platform has been to do with quake, and I don't have a *nix box set up at home right now to try, so I may be mistaken, but surely I could write the code to read a single char in DOS in ANSI C, and compile that on a unix box & run it without much issue???
Now if someone can tell me how to take a single character
without requiring enter to be pressed, that'd also be ace.
Well, the only function I know is getch()... not sure if it's the
best way to do it though, haven't done C code for aaaages
getc, fgetc, getchar - getch() would likely work, but is not
only on windows.. you need to do termios stuff on unix
struct termios term;
term.c_lflag &= ~ICANON; // turn off cooked mode
term.c_cc[VMIN] = 0; // no minimum chars
term.c_cc[VTIME] = 0; // no hold-keys for time
tcsetattr(0, TCSANOW, &term)
// read one char/key from tty
i = read(0, &ch, 1);
tcsetattr(0, TCSANOW, &origterm) // restore original settings
*Cough* *Hack* *Splutter*
You're saying that I can't read a single character under unix
using only ANSI C? Or did I miss something?