fprintf


fprintf

Writes formatted output to an open file

 #include <stdio.h> int fprintf ( FILE * restrict fp , const char * restrict format , ... ); 

The fprintf( ) function is similar to printf( ), but writes its output to the stream specified by fp rather than to stdout.

Example

 FILE *fp_log; time_t sec; fp_log = fopen("example.log", "a"); if ( fp != NULL) {   time(&sec);   fprintf( fp_log, "%.24s Opened log file.\n", ctime( &sec ) ); } 

This code appends the following output to the file example.log:

 Wed Dec  8 21:10:43 2004 Opened log file. 

See Also

printf( ), sprintf( ), snprintf( ), declared in stdio.h; vprintf( ), vfprintf( ), vsprintf( ), vsnprintf( ), declared in stdio.h and stdarg.h; the wide-character functions wprintf( ), fwprintf( ), swprintf( ), declared in stdio.h and wchar.h; vwprintf( ), vfwprintf( ), and vswprintf( ), declared in stdio.h, wchar.h, and stdarg.h; the scanf( ) input functions. Argument conversion in the printf( ) family of functions is described under printf( ) in this chapter.



C(c) In a Nutshell
C in a Nutshell (In a Nutshell (OReilly))
ISBN: 0596006977
EAN: 2147483647
Year: 2006
Pages: 473

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net