Syntax
#include <stdio.h> size_t fwrite(const void *buffer, size_t size, size_t count, FILE *stream);Description
fwrite writes up to count items, each of size bytes in length, from buffer to the output stream.
fwrite returns the number of full items successfully written, which can be fewer than count if an error occurs.
This example writes NUM long integers to a stream in binary format.
#include <stdio.h> #define NUM 100 int main(void) { FILE *stream; long list[NUM]; int numwritten; stream = fopen("myfile.dat", "w+b"); /* assign values to list[] */ numwritten = fwrite(list, sizeof(long), NUM, stream); printf("Number of items successfully written : %d\n", numwritten); return 0; /**************************************************************************** The output should be: Number of items successfully written : 100 ****************************************************************************/ }Related Information