standard.C.io.fputc

fputc is available since version 1.0.

Prototype:

string fputc(string ch, number fd)

Parameters

ch
[in] Character to be written
fd
[in] A valid file descriptor

Description:

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.

Return value:

fputc returns the written character.

Example
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