B
Blah
Lefteris Kororos said:You need to account for the NULL terminator of the string.Dan said:char buf[100];
int x;
while (fgets(buf, sizeof(buf)-1, stdin) != NULL) {
^^^^^^^^^^^^^
Where does the -1 come from?
Dan
I don't have any documentation handy, but IIRC fgets() handles that
detail for you, making the -1 above useful only if you want two bytes
available at the end of your buffer.