_eof

파일 끝 (EOF)에 대 한 테스트입니다.

int _eof( 
   int fd 
);

매개 변수

  • fd
    파일 설명자를 열린 파일을 참조 합니다.

반환 값

_eof그렇지 않은 경우 현재 위치가 파일 끝 또는 0 인 경우 1을 반환 합니다.반환 값이-1로 오류를 나타냅니다. 설명에 따라 잘못 된 매개 변수 처리기 호출 되는 경우 매개 변수 유효성 검사.실행을 계속 수 있으면 errno 으로 설정 EBADF, 잘못 된 파일 설명자를 나타냅니다.

설명

_eof 함수를 파일 끝 연결 여부 확인 fd 에 도달 했습니다.

요구 사항

Function

필수 헤더

선택적 헤더

_eof

<io.h>

<errno.h>

더 많은 호환성 정보를 참조 하십시오. 호환성 소개에서 합니다.

예제

// crt_eof.c
// This program reads data from a file
// ten bytes at a time until the end of the
// file is reached or an error is encountered.
//
#include <io.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <share.h>

int main( void )
{
   int  fh, count, total = 0;
   char buf[10];
   if( _sopen_s( &fh, "crt_eof.txt", _O_RDONLY, _SH_DENYNO, 0 ) )
   {
        perror( "Open failed");
        exit( 1 );
   }
   // Cycle until end of file reached: 
   while( !_eof( fh ) )
   {
      // Attempt to read in 10 bytes: 
      if( (count = _read( fh, buf, 10 )) == -1 )
      {
         perror( "Read error" );
         break;
      }
      // Total actual bytes read 
      total += count;
   }
   printf( "Number of bytes read = %d\n", total );
   _close( fh );
}

입력: crt_eof.txt

This file contains some text.

2hwz7wst.collapse_all(ko-kr,VS.110).gifOutput

Number of bytes read = 29

해당 .NET Framework 항목

해당 사항 없음. 표준 C 함수를 호출할 수 있습니다 PInvoke. 자세한 내용은 플랫폼 호출 예제.

참고 항목

참조

오류 처리 (CRT)

하위 수준 I/O

clearerr

feof

ferror

perror, _wperror