[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
fputc()                  Write a Character to a Stream

 #include   <stdio.h>

 int        fputc(c,stream);
 int        c;                           Character to be written
 FILE       *stream;                     Pointer to file structure

    fputc() writes a single character to 'stream' at the current
    position.

    Returns:    The character written, if successful.  EOF is returned to
                indicate an error.  Since EOF is a legitimate integer
                value, use ferror() to verify an error condition.

      Notes:    fputc() is identical to putc(), except that fputc() is a
                function and putc() is a macro.

  -------------------------------- Example ---------------------------------

    The following statements open a file and write the contents of a
    buffer to it.

         #include <stdio.h>

         FILE *stream;
         char buffr[10] = "0123456789";
         int i;
         int ch;

         main()
         {
             if ((stream = fopen("num.dta","r+")) != NULL) {
                  for (i = 0; i <= 9; i++)
                      if ((ch = fputc(buffr[i],stream)) != EOF)
                                ;
             }
         }

See Also: putchar() putc() fgetc() fgetchar()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson