Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/e/eof.html on line 1

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/e/eof.html on line 1

Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/e/eof.html on line 8

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/e/eof.html on line 8

eof()

Test if the end-of-file has been reached

Synopsis:

#include <unistd.h>

int eof( int filedes );

Arguments:

filedes
A file descriptor for the file that you want to check.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The eof() function is a low-level function that determines if the end of the file specified by filedes has been reached.

Input operations set the current file position; you can call the eof() function to detect the end of the file before more input operations to prevent attempts at reading beyond the end of the file.

Returns:

1
The end-of-file has been reached.
0
The end-of-file hasn't been reached.
-1
An error occurred (errno is set).

Errors:

EBADF
The file descriptor, filedes, isn't valid.

Examples:

#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>

int main( void )
{
    int filedes , len;
    char buffer[100];

    filedes = open( "file", O_RDONLY );
    if( filedes != -1 ) {
        while( ! eof( filedes ) ) {
            len = read( filedes , buffer, sizeof(buffer) - 1 );
            buffer[ len ] = '\0';
            printf( "%s", buffer );
        }
        close( filedes );
        
        return EXIT_SUCCESS;
    }
    
    return EXIT_FAILURE;
}

Classification:

QNX 4

Safety:
Cancellation point Yes
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

errno, feof(), open(), read()


Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/e/eof.html on line 168

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/e/eof.html on line 168