Chapter

Binary Files

From ComputerScienceOne by Dr Chris Bourke

Concepts

  1. How can you read a text file one line at a time?

    "22. File I/O\n\n4 //read the first line\n\n5 char *s = fgets(line, 1000, input);\n\n6 while(s != NULL) {\n\n7\n\n8 //chomp the endline character from line:\n\n9 line[strlen(line)-1] = '\\0';\n\n10\n\

  2. How do fread and fwrite read and write binary data?

    "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\ns

Binary Files | ComputerScienceOne | Bifalgorithm | Bifalgorithm