Export (0) Print
Expand All
div
Expand Minimize
4 out of 11 rated this helpful - Rate this topic

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.

Return Value

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.

Remarks

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.

Requirements

Function Required header Compatibility
fwrite <stdio.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

See the example for fread.

See Also

Stream I/O Routines | fread | _write | Run-Time Routines and .NET Framework Equivalents

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.