Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo C ) - <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:     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 true 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)
                             printf("%c ",ch);
               }
           }


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

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