Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C 6.0 - <b>fputc() write a character to a stream</b> http://www.X-Hacker.org [<<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:    On success, the character written; EOF is returned to
                indicate an error.  Because EOF is also a legitimate
                integer value, ferror() should be used to verify an
                actual error condition.

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

                fputchar() is a similar function that writes to stdout;
                fputc(c, stdout) and fputchar(c) are equivalent.

   -------------------------------- 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)
                             printf("%c ",ch);    }
           }


See Also: fputchar() putchar() putc() fgetc() fgetchar()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson