https://man7.org/linux/man-pages/man3/fgets.3p.html
The fgets() function shall read bytes from stream into the array pointed to by s until n-1 bytes are read, or a <newline> is read and transferred to s, or an end-of-file condition is encountered. A null byte shall be written immediately after the last byte read into the array. If the end-of-file condition is encountered before any bytes are read, the contents of the array pointed to by s shall not be changed.
fgets는 n-1 바이트를 읽거나, 개행 문자를 읽거나, EOF가 될 때까지 읽은 뒤 마지막으로 읽은 바이트 뒤에 '\0'을 첨가합니다. 한 가지 예외로 바이트를 1개도 읽기 전에 EOF라면 '\0' 첨가도 하지 않고 바로 종료합니다. 이 사실을 바탕으로 다음 반례를 살펴봅시다.
aaaaaaaaaaaaaaa bbbbbbbbbbbbbbb C D E [o] abCDEabababababababababababababab [x] abCabababababababababababababab
1. 15바이트를 읽습니다. a 15개를 읽어서 board의 0행에 씁니다. 첫 번째 개행 문자는 아직 남아 있습니다.
2. 다시 15바이트를 읽으려고 했는데, 처음 문자가 아까 안 읽었던 개행 문자입니다. 그래서 개행 문자 1개만 읽고 board의 1행에 쓰고 종료합니다. 여기가 문제의 시작입니다.
3. 다시 15바이트를 읽습니다. b 15개를 읽었지만, 이것은 board의 1행이 아닌 2행에 저장됩니다.

whwndgh1234 2년 전
해당 예제를 txt로 저장하여 입력으로 받아 디버깅까지 진행해보았지만 출력 배열에 null 문자 ('\0') 혹은 개행문자 ('\n')는 없었습니다.
문제 해결에 도움주시면 감사하겠습니다.