fwrite function
Supplement:
Function:
C language function, writes a data block to the file
2 Usage:
size_t fwrite(const void* buffer, size_t size, size_t count, FILE* stream);
Note: This function operates on files in binary form , not limited to text files
Return value: Returns the number of data blocks actually written
(1) buffer: is a pointer, for fwrite, it is used to obtain data Address;
(2) size: the number of single bytes to be written;
(3) count: the number of data items to be written to size bytes;
(4) stream: target file pointer;
(5) Return count of the number of data items actually written.
Description: Where to write to the file? This is related to the opening mode of the file. If it is w+, it will start writing from the address pointed to by the file pointer, and replace the subsequent content. The length of the file can remain unchanged, and the position of the stream will be moved by the count number; if it is a+, it will start from the address pointed to by the file pointer. Begin to add at the end of the file, and the file length will increase.
fseek has an effect on this function, but the fwrite[1] function writes to the user space buffer and is not synchronized to the file. Therefore, if you want to synchronize the memory with the file after modification, you can use fflush (FILE *fp ) function synchronization.