CompuServe Messages

gets fgets use

    24-Apr-94 11:26:32
Sb: #40723-gets fgets use
Fm: John Draper 76703,4322
To: Henry Williams 73527,1446
Henry, I tried your first example, as follows: #include <stdio.h> int main(void) { char buf[81]; while (gets (buf) != (char*) NULL) printf("%s\n",buf); } This works just fine for me. Your comment about it 'staying in the loop may be because of a misunderstanding of the return value from gets(). You will only get the NULL if EOF is reached before ANY characters are present in the keyboard buffer. That is, if you type anything at all, it will be echoed, including just typing a <RETURN>. The EOF key on the Amiga is a CTRL-\ (CONTROL-Backslash), and pressing that key before any other keys, after entry to the gets(), will drop you out of the loop. changing the program to: gets(buf); printf("%s\n",buf); works as expected, echoing the input, then dropping out. You didn't mention which compiler you are using, but the above examples I tried on Lattice. -larry