[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]


fwrite

Write binary data to a stream.

Compatibility:

This function is compatible with the following targets:

ANSI

BeOS

EMB/RTOS

Mac OS

Palm OS

Win32


Prototype:
#include <stdio.h>
size_t fwrite(const void *ptr, size_t size, 
   size_t nmemb, FILE *stream);
Parameters:

Parameters for this facility are:

ptr  
void *  
A pointer to the item being written  
size  
size_t  
The size of the item being written  
nmemb  
size_t  
The number of elements being written  
stream  
FILE *  
A pointer to a FILE stream  

Remarks:

The fwrite() function writes nmemb items of size bytes each to stream. The items are contained in the array pointed to by ptr. After writing the array to stream, fwrite() advances the file position indicator accordingly.

If the file is opened in update mode (+) the file cannot be written to and then read from unless the write operation and read operation are separated by an operation that flushes the stream's buffer. This can be done with the fflush() function or one of the file positioning operations (fseek(), fsetpos(), or rewind()).


NOTE

On embedded/ RTOS systems this function only is implemented for stdin, stdout and stderr files.
Return:

fwrite() returns the number of elements successfully written to stream.

See Also:

"Wide Character and Byte Character Stream Orientation"

"fread"

For example of fwrite() sage:
Refer to "Example of fread() usage." for fread().


[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.

Last updated: August 16, 2000