Message from C, C++ discussions
Char* fgets( char* str, int count, std::FILE* stream );
Reads at most count - 1 characters from the given file stream and stores them in the character array pointed to by str. Parsing stops if a newline character is found, in which case str will contain that newline character, or if end-of-file occurs. If bytes are read and no errors occur, writes a null character at the position immediately after the last character written to str.
The behavior is undefined if count is less than 1. It is also not specified whether a null character is written if count==1.