For the latest documentation on Visual Studio 2017 RC, see Visual Studio 2017 RC Documentation.
Writes data to a stream.
size_t fwrite( const void *buffer, size_t size, size_t count, FILE *stream );
Pointer to data to be written.
Item size, in bytes.
Maximum number of items to be written.
fwrite returns the number of full items actually written, which may be less than
count if an error occurs. Also, if an error occurs, the file-position indicator cannot be determined. If either
buffer is a null pointer, or if an odd number of bytes to be written is specified in Unicode mode, the function invokes the invalid parameter handler, as described in Parameter Validation. If execution is allowed to continue, this function sets
EINVAL and returns 0.
fwrite function writes up to
count items, of
size length each, from
buffer to the output
stream. The file pointer associated with
stream (if there is one) is incremented by the number of bytes actually written. If
stream is opened in text mode, each linefeed is replaced with a carriage-return – linefeed pair. The replacement has no effect on the return value.
stream is opened in Unicode translation mode—for example, if
stream is opened by calling
fopen and using a mode parameter that includes
ccs=UTF-8, or if the mode is changed to a Unicode translation mode by using
_setmode and a mode parameter that includes
buffer is interpreted as a pointer to an array of
wchar_t that contains UTF-16 data. An attempt to write an odd number of bytes in this mode causes a parameter validation error.
Because this function locks the calling thread, it is thread-safe. For a non-locking version, see
For additional compatibility information, see Compatibility.
See the example for fread.