← Back to Home

CITS2002 - Lecture 7
Computer Hardware - Slides
File Input and Output - Slides

Using Files

Using fopen():

  • In different applications, we may need to open a file in different ways:
    “r” open for reading
    “r+” open for reading and writing
    “w” create or truncate file, then open for writing
    “w+” create or truncate file, then open for reading and writing
    “a” create if necessary, then open for appending (at the end of the file)
    “a+” create if necessary, then open for reading and appending
  • Truncate means to empty a file, but to still keep the file
    i.e. clear a file

CITS2002 - Lecture 9