Concept

How do fread and fwrite read and write binary data?

ComputerScienceOne / Binary Files

"22.2.2. Binary Files\n\nTo read and write binary data to files we use two different functions:\n\nsize_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream);\n\nfor reading from a file and\n\nsize_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);\n\nto write to a file. Both functions have the exact same arguments:\n\n1. ptr is a pointer to the item that is being read/written (possibly an array of elements)\n\n2. size is the number of bytes that each element stored at ptr take, usually determined by using sizeof()\n\n3. nmemb is the number of elements to be written/read\n\n4. stream is the file stream to be read from/written to\n\nThese functions allow you to read/write an arbitrary amount of binary data. When reading, it is your responsibility, as usual, to ensure that the ptr is large enough to"

Related Ideas

How do fread and fwrite read and write binary data? | ComputerScienceOne | Bifalgorithm | Bifalgorithm