O'Reilly logo

Just Enough C/C++ Programming by Guy W. Lecky-Thompson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using fprintf

The first of the formatted I/O functions covered here is parallel to the printf function you learned about in Chapter 5. It is called fprintf and allows you to output text to a file that has been opened for writing (or reading and writing).

The fprintf function allows you to output data to the file exactly as if it were outputting to the screen. The definition of fprintf is as follows:

int fprintf (FILE * stream,
       const char * format [, argument list]);

The [argument list] will depend on the contents of the format parameter; it may be that there are zero parameters or many, depending on how many translatable data fields exist in format. In this respect, the function is identical to the standard printf. The file handle is provided ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required