int fputws (const wchar_t* ws, FILE* stream);
Write wide string to stream
Writes the wide C string pointed by ws to the stream.
The function begins copying from the address specified (ws) until it reaches the terminating null wide character. This terminating null wide character is not copied to the stream.
The external representation of wide characters in files are multibyte characters: These are obtained as if wcrtomb was called to convert each wide character (using the stream's internal mbstate_t object).
This is the wide character equivalent of fputs (<cstdio>).
- C wide string with the content to write to the stream.
- Pointer to a FILE object that identifies an output stream.
The stream shall not have an orientation yet, or be wide-oriented (the first i/o operation on a stream determines whether it is byte- or wide- oriented, see fwide).
On success, a non-negative value is returned.
If a multibyte character encoding error occurs, errno is set to EILSEQ and EOF is returned.
If a writing error occurs, the function sets the error indicator (ferror) and also returns EOF.
/* fputws example */
int main ()
FILE * pFile;
wchar_t sentence ;
wprintf (L"Enter sentence to append: ");
pFile = fopen ("mylog.txt","a");
This program allows to append a line to a file called mylog.txt each time it is run.
- Write string to stream (function)
- Get wide string from stream (function)
- Write wide character to stream (function)
- Write formatted data to stream (function)