By convention, strings in C are "NUL-terminated". This means that the end of strings are determined by the presence of a "NUL" character. The NUL character is the character '\0'
or more specifically a char
with a value of 0. All C string literals are NUL-terminated, and most C APIs that take strings (both in the standard library and in most other libraries written in C) expect those strings to be NUL terminated.
This also means that a NUL character cannot be used as a normal data value in APIs that expect NUL terminations. Those APIs will treat the NUL character, not as a meaningful part of the string's data, but as the end of the string. For example, strlen("foo\0bar")
is 3, not 7.
fgets
reads character data from a file stream. But that file can contain NUL characters. What that post is saying is that fgets
will treat NUL characters in the file exactly like any other character. fgets
does NUL-terminate the string it is given, but if the file contains NUL characters, fgets
will dutifully read them.
This is what the post is warning about: fgets
does not treat NUL characters differently from any other character, while most other C API functions do. So if you pass a string generated by fgets
to some API that expects NUL-termination, you may have a problem if that file contained NUL characters.