CompuServe Thread

#C help!

2 messages in this thread
#41441From: George S. RolandJun 16, 1994 11:12 PM
I am trying to learn C with a young man who has some experience with it but not on the Amiga. I am using SAS C V.6.5. We are trying to read a series of characters from the keyboard with spaces between and not knowing how many characters there are. He tells me getchar() does this in most C implementations. If one typed 45 30 56 at the keyboard (with spaces between as shown) then getchar() would detect the spaces and print the numbers one overtop of the other, each on its own line rather than all on one line as they originally were. Is there an equivalent function in Amiga C? One that would return 45 30 56 Any help would be appreciated. George
#41445From: Jim ButterfieldJun 17, 1994 7:11 AM
George: Function c=getchar(void) should work fine, provided you understand that a standard console window gives you NOTHING until the Enter key is pressed (before that time, the user has a chance to change or correct the input line). In other words, the Amiga passes the entire line to the stdin input stream. To REALLY get one character at a time, as they are typed, you need a different type of window; not the CONsole window, but a RAW one. There are several ways to get one of these: open a RAW window; change the current window to RAW operation; or: SAS/C 6.5 function c=getch(void) will switch a console input to RAW, get a charcter, and then restore the window to its original state. You can read up on this stuff in the docs, Chapter 7, pages 280-281. When you reach the end of a line, you should read the Enter key as character 0x0A with either function call. –Jim