std:: ferror
From cppreference.net
C++
Input/output library
| I/O manipulators | ||||
| Print functions (C++23) | ||||
| C-style I/O | ||||
| Buffers | ||||
|
(C++23)
|
||||
|
(
C++98/26*
)
|
||||
|
(C++20)
|
||||
| Streams | ||||
| Abstractions | ||||
| File I/O | ||||
| String I/O | ||||
| Array I/O | ||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(
C++98/26*
)
|
||||
|
(
C++98/26*
)
|
||||
|
(
C++98/26*
)
|
||||
| Synchronized Output | ||||
|
(C++20)
|
||||
| Types | ||||
| Error category interface | ||||
|
(C++11)
|
||||
|
(C++11)
|
C-style I/O
| Types and objects | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Functions | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
헤더 파일에 정의됨
<cstdio>
|
||
|
int
ferror
(
std::
FILE
*
stream
)
;
|
||
주어진 스트림에 오류가 있는지 확인합니다.
목차 |
매개변수
| stream | - | 확인할 파일 스트림 |
반환값
파일 스트림에 오류가 발생한 경우 0이 아닌 값, 0 그 외의 경우.
예제
이 코드 실행
#include <clocale> #include <cstdio> #include <cstdlib> #include <cwchar> int main() { const char *fname = std::tmpnam(nullptr); std::FILE* f = std::fopen(fname, "wb"); std::fputs("\xff\xff\n", f); // 유효하지 않은 UTF-8 문자 시퀀스 std::fclose(f); std::setlocale(LC_ALL, "en_US.utf8"); f = std::fopen(fname, "rb"); std::wint_t ch; while ((ch=std::fgetwc(f)) != WEOF) // UTF-8로 읽기 시도 std::printf("%#x ", ch); if (std::feof(f)) puts("EOF 표시자 설정됨"); if (std::ferror(f)) puts("오류 표시자 설정됨"); }
출력:
오류 표시자 설정됨
참고 항목
|
오류를 지움
(함수) |
|
|
파일 끝을 확인함
(함수) |
|
|
오류 발생 여부를 확인함
(
std::basic_ios<CharT,Traits>
의
public 멤버 함수)
|
|
|
C 문서
for
ferror
|
|