Formats and prints a series of characters and values to the output stream.
int fprintf( FILE * stream, const char * format, ... )
Returns the number of bytes written. Returns a negative value instead when an output error occurs.
EX1
//The following example uses fprintf to format various data and print it to the file named fprintf.out. void test_fprintf() { FILE *stream; int i = 10; double fp = 1.5; char s[] = "this is a string"; char c = '\n'; stream = fopen( "fprintf.out", "w" ); if(stream == NULL) printf( "The file fprintf.out was not opened\n" ); fprintf( stream, "%s%c", s, c ); fprintf( stream, "%d\n", i ); fprintf( stream, "%f\n", fp ); fclose( stream ); }
Formats and prints a series of characters and values to the output stream. Each function argument (if any) is converted and output according to the corresponding format specification in format. For fprintf, the format argument has the same syntax and use that it has in printf.
fscanf
origin.h