со страницы руководства fgets(3)
:
ОПИСАНИЕ
fgets() reads in at most one less than size characters from stream and
stores them into the buffer pointed to by s. Reading stops after an
EOF or a newline. If a newline is read, it is stored into the buffer.
A '\0' is stored after the last character in the buffer.
...
ВОЗВРАЩАЕМОЕ ЗНАЧЕНИЕ
...
gets() and fgets() return s on success, and NULL on error or when end
of file occurs while no characters have been read.
Исходя из этого, можно сделать вывод, что size
из 1
заставит его прочитать пустую строку.Эксперименты здесь подтверждают, что.
Между прочим, size
из 0
, кажется, вообще не изменяет буфер, даже не вставляя \0
.