File open mode : File Stream in C Programming
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 ?
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 :
- File can be opened in basic 3 modes : Reading Mode, Writing Mode, Appending Mode
- If File is not present on the path specified then New File can be created using Write and Append Mode.
- Generally we used to open following types of file in C -
File Type | Extension |
---|---|
C Source File | .c |
Text File | .txt |
Data File | .dat |
- Writing on the file will overwrite previous content