clearerr_s

스트림에 대한 오류 표시기를 다시 설정합니다. 이 함수는 CRTclearerr 보안 기능에 설명된 대로 보안 기능이 향상된 버전입니다.

구문

errno_t clearerr_s(
   FILE *stream
);

매개 변수

stream
FILE 구조체에 대한 포인터입니다.

반환 값

성공하면 0, EINVAL if stream is .NULL

설명

clearerr_s 함수는 stream에 대한 오류 표시기 및 파일 끝 표시기를 다시 설정합니다. 오류 표시기가 자동으로 지워지지 않습니다. 지정된 스트림에 대한 오류 표시기가 설정되면 해당 스트림에 대한 작업은 , , fsetposclearerrfseek또는 rewind 호출될 때까지 clearerr_s계속해서 오류 값을 반환합니다.

이 경우 stream 매개 변수 유효성 검사에 설명된 대로 잘못된 매개 변수 처리기가 호출NULL됩니다. 계속해서 실행하도록 허용한 경우 이 함수는 errnoEINVAL로 설정하고 EINVAL을 반환합니다.

기본적으로 이 함수의 전역 상태는 애플리케이션으로 범위가 지정됩니다. 이 동작을 변경하려면 CRT의 전역 상태를 참조하세요.

요구 사항

루틴에서 반환된 값 필수 헤더
clearerr_s <stdio.h>

호환성에 대한 자세한 내용은 호환성을 참조하세요.

예시

// crt_clearerr_s.c
// This program creates an error
// on the standard input stream, then clears
// it so that future reads won't fail.

#include <stdio.h>

int main( void )
{
   int c;
   errno_t err;

   // Create an error by writing to standard input.
   putc( 'c', stdin );
   if( ferror( stdin ) )
   {
      perror( "Write error" );
      err = clearerr_s( stdin );
      if (err != 0)
      {
         abort();
      }
   }

   // See if read causes an error.
   printf( "Will input cause an error? " );
   c = getc( stdin );
   if( ferror( stdin ) )
   {
      perror( "Read error" );
      err = clearerr_s( stdin );
      if (err != 0)
      {
         abort();
      }
   }
}

입력

n

출력

Write error: Bad file descriptor
Will input cause an error? n

참고 항목

오류 처리
스트림 I/O
clearerr
_eof
feof
ferror
perror, _wperror