File open mode : File Stream in C Programming

February 5, 2012 No Comments » Hits : 453





file open mode : File Stream in C Programming

In this tutorial we are going to review all file opening modes in C Programming Language (File Handling).
Refer this article before : What is FILE Pointer ?


ModeMeaningfopen Returns if  FILE-
Exists Not Exists
rReading-NULL
wWritingOver write on ExistingCreate New File
aAppend-Create New File
r+Reading + WritingNew data is written at the beginning overwriting existing dataCreate New File
w+Reading + WritingOver write on ExistingCreate New File
a+Reading + AppendingNew data is appended at the end of fileCreate New File

Explanation :

  1. File can be opened in basic 3 modes.
    • Read Mode
    • Write Mode
    • Append Mode
  2. If File is mot present then New File can be created using Write and Append Mode.
  3. Generally we used to open following types of file in C -
    • C Source File (.c)
    • Text File (.txt)
    • Data File (.dat)
  4. Writing on the file will overwrite previous content.

Incoming search terms: