Hi numero,
I assume you're using MetroWerks' CodeWarrior IDE? If so, there's a special 'getch()' function that allows "immediate" character reads in a Mac SIOUX (console) app. [You'd need to '#include <console.h>' to pull in the 'getch()' prototype.] Note that there is one quirk involved in calling 'getch()' -- viz., it doesn't echo the user's typed char(s) back to the screen. So, to provide feedback when the user types a non-ESC char (i.e., the first char of a student-ID string), you'd need to explicitly echo that char by calling an output function such as 'putchar()'.
If the user has indeed typed a non-ESC char, you could also "undo" the 'getch()' read, thus restoring that char to the 'stdin' input stream, by calling 'ungetc( char, stdin )'. You could then just call an input function like 'gets()' to read (& auto-echo) the entire ID string as usual. [Or, alternatively you could continue making calls to 'getch()' & 'putchar()' in a loop to read & echo the remaining ID chars (exiting when you get a certain keystroke such as the '\r' Return char). Within the loop, you'd also need to call something like 'strcat()' to "accumulate" each successive char into a complete ID string. One potential advantage of this latter approach is that it would allow the user to press the ESC key at any point during the typing of the ID string.]
There are probably many better ways to accomplish all of this, but the above approaches would work okay as first stabs at a solution. Of course, the 'getch()' function isn't a standard ANSI routine, so it might not be acceptable for your assignment. Unfortunately, the "buffering" of the 'stdin' input stream cannot normally be disabled via the 'setbuf()' function, nor can it be bypassed by using other input functions like 'scanf()'... I don't remember if Apple's own MPW IDE automatically implements an "immediate" mode for the standard 'getchar()' function?
Regards,
--Paul
[This message has been edited by Paul Crawford (edited 03-12-2001).]