Concept Framework 1.0 documentation Contents | Index

standard.C.io.feof

Name Version Deprecated
feof version 1.0 no

Prototype:
number feof(number fd)

Parameters:
fd      [in] A valid file descriptor

Description:
The feof function tests for end-of-file on a stream.
It returns a nonzero value after the first read operation that attempts to read past the end of the file. It returns 0 if the current position is not end of file.

Example:
import standard.C.io

import standard.C.string

define FILENAME "test.txt"

class Main {
function Main() {
var fd;
var count;
var total;
var buffer = "";

// Open file for read
if (fd = fopen(FILENAME, "r")) {
// Cycle until end of file reached
while(!feof(fd)) {
// Attempt to read in 10 bytes:
count = fread(buffer, 1, 10, fd);
// Total up actual bytes read
total += count;
echo buffer;
}
echo "Number of bytes read $total\n";
} else
echo "Problem opening the file\n";

}
}

Results
This is the file 'test.txt'.
Second line.
Number of bytes read 42

Returns:
It returns a nonzero value after the first read operation that attempts to read past the end of the file. It returns 0 if the current position is not end of file.

Documented by Simona Plesuvu, generation time: Thu Oct 15 20:02:04 2009 GMT(c)2009 RadGs Software