| Concept Framework 2.2 documentation | Contents | Index |
| Name | Version | Deprecated |
| fgetc | version 1.0 | no |
| string fgetc(number fd) |
| fd | [in] A valid file descriptor |
|
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.
|
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.
|
| Documented by Simona Plesuvu, generation time: Sun Jan 27 18:15:16 2013 GMT | (c)2013 Devronium Applications |