Namespaces
Variants

std:: clearerr

From cppreference.net
< cpp ‎ | io ‎ | c
헤더 파일에 정의됨 <cstdio>
void clearerr ( std:: FILE * stream ) ;

주어진 파일 스트림에 대한 오류 플래그와 EOF 지시자를 재설정합니다.

목차

매개변수

stream - 오류 플래그를 재설정할 파일

반환값

(없음)

예제

#include <cassert>
#include <cstdio>
int main()
{
    std::FILE* tmpf = std::tmpfile();
    std::fputs("cppreference.net\n", tmpf);
    std::rewind(tmpf);
    for (int ch; (ch = std::fgetc(tmpf)) != EOF; std::putchar(ch)) { }
    assert(std::feof(tmpf)); // 루프가 EOF로 종료될 것으로 예상됨
    std::puts("End of file reached");
    std::clearerr(tmpf); // EOF 클리어
    std::puts(std::feof(tmpf) ? "EOF indicator set"
                              : "EOF indicator cleared");
}

출력:

cppreference.net
End of file reached
EOF indicator cleared

참고 항목

파일 끝 확인
(함수)
현재 오류에 해당하는 문자열을 stderr 에 출력
(함수)
파일 오류 확인
(함수)
C documentation for clearerr