CITS2002 Systems Programming  
prev
next CITS2002 CITS2002 schedule  

Reading and writing files of binary data

To date, our use of files has dealt exclusively with lines of text, using fgets() and fputs() to perform our I/O.

This has provided a good introduction to file input/output (I/O) as textual data is easy to "see", and printing it to the screen helps us to verify our functions:

  • the standard fgets function manages the differing lengths of input lines by reading until the '\n' or '\r' character is found,

  • fgets terminates input lines by appending a null-byte to them, 'turning' them into C strings, and

  • the null-byte is significant when later managing (copying, printing, ...) strings.

 


CITS2002 Systems Programming, Lecture 8, p12, 15th August 2023.