종료 조건이 불완전합니다.
fgets 함수는 줄바꿈 문자를 만나면 줄바꿈 문자도 buffer 에 넣습니다.
즉, 데이터의 종료를 나타내는 문자열은 ".\n" 이 됩니다.
4949번 - 균형잡힌 세상
다른 분들에게도 도움이 될 수 있을 것 같아 관련 내용도 같이 첨부합니다.
char *fgets( char *restrict str, int count, FILE *restrict 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`.
댓글을 작성하려면 로그인해야 합니다.
jdeokkim 2년 전
제출 결과: "틀렸습니다"