Concept Framework 1.0 documentation Contents | Index

standard.C.io.fclose

Name Version Deprecated
fclose version 1.0 no

Prototype:
number fclose(number fd)

Parameters:
fd      [in] Descriptor for the file to close

Description:
Closes a file opened with fopen.

Example:
import standard.C.io


class Main {
function Main() {
// Open for read (will fail if file "test1.txt" does not exist)
if(!(var fd1 = fopen( "test1.txt", "r" )))
echo "The file 'test1.txt' was not opened\n";
else {
echo "The file 'test1.txt' was opened\n";
// Close the file
if(fclose(fd1) != 0)
echo "The file 'test1.txt' was not closed\n";
}

// Open for write
if(!(var fd2 = fopen( "test2.txt", "w+" )))
echo "The file 'test2.txt' was not opened\n";
else {
echo "The file 'test2.txt' was opened\n";
// Close the file
if(fclose(fd2) != 0)
echo "The file 'test2.txt' was not closed\n";

}
}
}


Results
The file 'test1.txt' was not opened
The file 'test2.txt' was opened

Returns:
fclose returns 0 if the file is successfully closed.

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