fputs, fputws
Write a string to a stream.
int fputs( const char *string, FILE *stream ); int fputws( const wchar_t *string, FILE *stream );
Parameters
- string
- Output string.
- stream
- 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.
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 |
Requirements
| 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.
Libraries
All versions of the C run-time libraries.
Example
// 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.
See Also
Stream I/O Routines | fgets | gets | puts | _putws | Run-Time Routines and .NET Framework Equivalents