This documentation is archived and is not being maintained.

fputs, fputws

Write a string to a stream.

int fputs( 
   const char *string,
   FILE *stream 
int fputws( 
   const wchar_t *string,
   FILE *stream 


Output string.
Pointer to FILE structure.

Return Value

Each of these functions returns a nonnegative value if it is successful. On an error, fputs returns EOF, and fputws returns WEOF.


Each of these functions copies string to the output stream at the current position. fputws copies the wide-character argument string to stream as a multibyte-character string or a wide-character string according to whether stream is opened in text mode or binary mode, respectively. Neither function copies the terminating null character.

Generic-Text Routine Mappings

TCHAR.H routine _UNICODE & _MBCS not defined _MBCS defined _UNICODE defined
_fputts fputs fputs fputws


Function Required header Compatibility
fputs <stdio.h> ANSI, Win 98, Win Me, Win NT, Win 2000, Win XP
fputws <stdio.h> or <wchar.h> ANSI, Win 98, Win Me, Win NT, Win 2000, Win XP

For additional compatibility information, see Compatibility in the Introduction.


All versions of the C run-time libraries.


// crt_fputs.c
/* This program uses fputs to write
 * a single line to the stdout stream.

#include <stdio.h>

int main( void )
   fputs( "Hello world from fputs.\n", stdout );


Hello world from fputs.

See Also

Stream I/O Routines | fgets | gets | puts | _putws | Run-Time Routines and .NET Framework Equivalents