Go to: Return value. Related commands. Examples.

Synopsis

feof <int>

Returns non-zero if end of file is reached. Note that if an empty file is opened, feof will not detect that it is at the end of the file until at least one read is performed.

Return value

int

Related commands

popen, pclose, fgetline, fgetword, fopen, fclose, fflush, fprint, fread, frewind, fwrite

Examples


	// Make a sample file to use as a test example
	//
	$exampleFileName = ( `internalVar -userTmpDir` + "example.tmp" );
	$fileId=`fopen $exampleFileName "w"`;
	fprint $fileId "Hello there\nuser";
	fclose $fileId;
	//
	// Now read it back one word at a time, checking for the end of the file
	//
	$fileId=`fopen $exampleFileName "r"`;
	while ( !`feof $fileId` ) {
		string $nextWord = `fgetword $fileId`;
		if ( size( $nextWord ) > 0 ) {
			print ( $nextWord + "\n" );
		}
	}
	fclose $fileId;