Compartir a través de


fprintf, fwprintf (Windows CE 5.0)

Send Feedback

Developing an Application > Microsoft C Run-time Library for Windows CE > Run-time Library Reference

Print formatted data to a stream.

int fprintf(    FILE* stream,const char*format [, argument ]...
);int fwprintf(    FILE*stream,const wchar_t*format [, argument ]...);

Parameters

  • stream
    Pointer to FILE structure.
  • format
    Format-control string.
  • argument
    Optional arguments.

Return Values

fprintf returns the number of bytes written.

fwprintf returns the number of wide characters written.

Both functions returns a negative value when an output error occurs.

Remarks

fprintf 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.

fwprintf is a wide-character version of fprintf; in fwprintf, format is a wide-character string. These functions behave identically otherwise.

Generic-Text Routine Mappings

TCHAR.H Routine _UNICODE Defined
_ftprintf fwprintf

For more information about Tchar.h routines, see Generic Text Mappings.

Example

/* FPRINTF.C: This program uses fprintf to format various
 * data and print it to the file named FPRINTF.OUT. 
 */

#include <stdio.h>

FILE *stream;

void main( void )
{
   int    i = 10;
   double fp = 1.5;
   char   s[] = "this is a string";
   char   c = '\n';

   stream = fopen( "fprintf.out", "w" );
   fprintf( stream, "%s%c", s, c );
   fprintf( stream, "%d\n", i );
   fprintf( stream, "%f\n", fp );
   fclose( stream );
}

Output

this is a string
10
1.500000

Requirements

OS Versions: Windows CE 2.0 and later.
Header: stdlib.h.
Link Library: coredll.dll.

See Also

fscanf | sprintf

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.