Export (0) Print
Expand All
div
eof
Expand Minimize

fputs, fputws 

Write a string to a stream.


int fputs( 
   const char *str,
   FILE *stream 
);
int fputws( 
   const wchar_t *str,
   FILE *stream 
);

Parameters

str

Output string.

stream

Pointer to FILE structure.

Each of these functions returns a nonnegative value if it is successful. On an error, fputs returns EOF, and fputws returns WEOF. If str or stream is a null pointer, these functions invoke the invalid parameter handler, as described in Parameter Validation. If execution is allowed to continue, these functions set errno to EINVAL and return EOF or WEOF.

See _doserrno, errno, _sys_errlist, and _sys_nerr for more information on these, and other, error codes.

Each of these functions copies str to the output stream at the current position. fputws copies the wide-character argument str 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.

The two functions behave identically if the stream is opened in ANSI mode. fputs does not currently support output into a UNICODE stream.

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, Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition, Windows NT 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003

fputws

<stdio.h> or <wchar.h>

ANSI, Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition, Windows NT 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003

For additional compatibility information, see Compatibility in the Introduction.

// 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 );
}

Output

Hello world from fputs.

Community Additions

ADD
Show:
© 2014 Microsoft