| Concept Framework 2.2 documentation | Contents | Index |
| Name | Version | Deprecated |
| fputc | version 1.0 | no |
| string fputc(string ch, number fd) |
| ch | [in] Character to be written |
| fd | [in] A valid file descriptor |
| fputc writes the single character ch to a file at the position indicated by the associated file position indicator (if defined) and advances the indicator as appropriate; the file is associated with fd. If the file cannot support positioning requests or was opened in append mode, the character is appended to the end of the stream. |
import standard.C.io
define FILENAME "test.txt"
class Main {
function Main() {
var fd;
var ch;
var i;
var buffer = "Test of fputc\n";
// Open file for write
if (fd = fopen(FILENAME, "w")) {
// Print line to stream using fputc
ch = buffer[0];
i = 0;
while (ch) {
fputc(ch, fd);
i++;
ch = buffer[i];
}
freopen(FILENAME, "r", fd);
buffer = "";
fread(buffer, 1, 15, fd);
echo "$buffer\n";
fclose(fd);
} else
echo "Problem opening the file\n";
}
}
Results
Test of fputc
|
| Documented by Simona Plesuvu, generation time: Sun Jan 27 18:15:16 2013 GMT | (c)2013 Devronium Applications |