fprintf() Write Formatted Data to Stream
#include <stdio.h>
int fprintf(stream,format-string[,argument...]);
FILE *stream; Pointer to file structure
char *format-string; Format control string
fprintf() formats and prints a series of characters and values to the
output 'stream'. If there are any 'arguments', they are converted
and output according to the specification 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: The number of characters printed.
-------------------------------- Example ---------------------------------
The following statements open a file and write formatted data to it.
#include <stdio.h>
FILE *stream;
char *name = "BOB SMITH";
int enum = 1;
char sex = 'M';
main()
{
if ((stream = fopen("results.dat","w+")) != NULL) {
fprintf(stream,"%d, %s, %c\n", enum, name, sex);
}
}
Seealso:
This page last updated on Fri Nov 30 10:48:32 MSK 2001
Copyright © 1992-2001, Vitaly Filatov, Moscow, Russia
Webmaster