문제 설명
새 줄이 발견되지 않으면 fget이 NULL을 반환하지 않습니다. (fgets dont return NULL when no new line found)
나는 while 루프를 사용하고 있습니다:
while(fgets(pclientRow, 1024 , f) != NULL)
다른 클래스에서는 잘 작동하지만 그 중 하나에서 파일에서 한 줄씩 읽을 때 줄이 끝날 때에도 루프를 벗어나지 않습니다. 디버거에서 보았습니다.
왜 그것은? 그리고 그것은 이전에 그 수업에서도 작동하고 있었고 지금은 충돌 할 때까지 왜 계속 빈 줄을 가져 오는지 모르겠습니다..
아무 생각이 있습니까?
참조 솔루션
방법 1:
fgets in a standard ANSI C function, see documentation: Here fgets read max. 1023 character up to next '\n' or EOF. Your lines are longer than 1023 character or the last line has no terminating newline.
방법 2:
You could catch the \n issue by placing something like this in your while loop.
if((int)strlen(pclientRow) == 1) break;
(by k‑man、user411313、davissp14)