fputs, fputws

Write a string to a stream.

intfputs(constchar*string,FILE*stream);

intfputws(constwchar_t*string,FILE*stream);

Function Required Header Compatibility
fputs <stdio.h> ANSI, Win 95, Win NT
fputws <stdio.h> or <wchar.h> ANSI, Win 95, Win NT

For additional compatibility information, see Compatibility in the Introduction.

Libraries

LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version

Return Value

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

Parameters

string

Output string

stream

Pointer to FILE structure

Remarks

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

Example

/* FPUTS.C: This program uses fputs to write
 * a single line to the stdout stream.
 */

#include <stdio.h>

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

Output

Hello world from fputs.

Stream I/O Routines

See Also   fgets, gets, puts, _putws