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 :

Mode Meaning fopen Returns if  FILE-
Exists Not Exists
r Reading NULL
w Writing Over write on Existing Create New File
a Append Create New File
r+ Reading + Writing New data is written at the beginning overwriting existing data Create New File
w+ Reading + Writing Over write on Existing Create New File
a+ Reading + Appending New data is appended at the end of file Create 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 Type Extension
C Source File .c
Text File .txt
Data File .dat

  1. Writing on the file will overwrite previous content