Concept Framework 1.0 documentation Contents | Index

standard.C.io.fgetc

Name Version Deprecated
fgetc version 1.0 no

Prototype:
string fgetc(number fd)

Parameters:
fd      [in] A valid file descriptor

Description:
fgetc reads a single character from the current position of a file associated with fd. The function then increments the associated file pointer (if defined) to point to the next character. If the stream is at end of file, the end-of-file indicator for the stream is set.


Example:
import standard.C.io


define FILENAME "test.txt"

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

// Open file for read
if (fd = fopen(FILENAME, "r")) {
// Read in the characters and place them in "buffer"
ch = fgetc(fd);
while (!feof(fd)) {
buffer+= ch;
ch = fgetc(fd);
}

echo "$buffer\n";
fclose(fd);
} else
echo "Problem opening the file\n";

}
}

Results
Line one.
Line two.

Returns:
fgetc returns the character read.

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