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>fprintf() write formatted data to stream</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 fprintf()               Write Formatted Data to Stream

 #include   <stdio.h>

 int        fprintf(stream,format-string[,argument...]);
 FILE       *stream;                     Pointer to FILE structure
 const char *format-string;              Format control string

    fprintf() prints formatted characters and values to the specified
    output 'stream'.  Any 'arguments' are converted and output as
    specified in 'format-string'.

    Except for the capability to specify the stream to print to,
    fprintf() is identical to printf().  The format string and arguments
    of fprintf() are identical to those of printf(); see printf() for a
    complete description of the format string and arguments.

    Returns:    Number of characters printed.

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

    The following statements open a file and write formatted data to it.

           #include <stdio.h>

           FILE *stream;
           char *name = "FRANK SMITH";
           int num = 100;
           char sex = 'M';
           char outstr[20];

           main()
           {
               if ((stream = fopen("results.dat","w+")) != NULL) {
                       fprintf(stream,"%d, %s, %c\n", num, name, sex);
                       rewind(stream);
                       fgets(outstr,20,stream);
                       printf(%s\n",outstr);
               }
           }


See Also: printf() fscanf() cprintf() sprintf()

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