C file open modes



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).
[box]Refer this article before : What is FILE Pointer ?[/box]

File Opening Mode Chart :

ModeMeaningfopen Returns if  FILE-
Exists Not Exists
rReadingNULL
wWritingOver write on ExistingCreate New File
aAppendCreate 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 : Reading Mode, Writing Mode, Appending Mode
  2. If File is not present on the path specified then New File can be created using Write and Append Mode.
  3. Generally we used to open following types of file in C
File TypeExtension
C Source File.c
Text File.txt
Data File.dat


  1. Writing on the file will overwrite previous content