B
Ben Bacarisse
Army1987 said:Or better, set buff[size - 1] to a nonzero value, call fgets, and[...]To find out
which we use strchr searching for '\0' which will always succeed. If the
NUL is at buff[size-1] we assume the line is longer than buff.
Doesn't strlen(buf) != size - 1 do the same without looking that
weird?
check whether buff[size - 1] is zero. This takes O(1) time.
This is a neat solution because it also works in the peculiar case of
a line with embedded nulls.