Writes a specified number of items to the file. Format #include <stdio.h> size_t fwrite (const void *ptr, size_t size_of_item, size_t number_items, FILE *file_ptr);
1 – Arguments
ptr A pointer to the memory location from which information is being written. The type of the object pointed to is determined by the type of the item being written. size_of_item The size, in bytes, of the items being written. number_items The number of items to be written. file_ptr A file pointer that indicates the file to which the items are being written.
2 – Description
The type size_t is defined in the header file <stdio.h> as follows: typedef unsigned int size_t The writing begins at the current location in the file. The items are written from storage beginning at the location given by the first argument. You must also specify the size of an item, in bytes. If the file pointed to by file_ptr is a record file, the fwrite function outputs at least number_items records, each of length size_of_item.
3 – Return Value
x The number of items written. The number of records written depends upon the maximum record size of the file.