Export (0) Print
Expand All
div
eof
Expand Minimize

fwrite 

Writes data to a stream.


size_t fwrite(
   const void *buffer,
   size_t size,
   size_t count,
   FILE *stream 
);

Parameters

buffer

Pointer to data to be written.

size

Item size in bytes.

count

Maximum number of items to be written.

stream

Pointer to FILE structure.

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 stream or buffer is a null pointer, the function invokes the invalid parameter handler, as described in Parameter Validation. If execution is allowed to continue, this function sets errno to EINVAL and returns 0.

The 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 carriage return is replaced with a carriage-return – linefeed pair. The replacement has no effect on the return value.

This function locks the calling thread and is therefore thread-safe. For a non-locking version, see _fwrite_nolock.

Function Required header Compatibility

fwrite

<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

For additional compatibility information, see Compatibility in the Introduction.

See the example for fread.

Community Additions

ADD
Show:
© 2014 Microsoft