Text File Handling in C
In this lesson, we will learn how to handle text file in C.
What is Text File Handling
Text File Handling is a process in which we create a text file and store data permanently on a hard disk, allowing it to be retrieved later for use in a program.
In a text file, all data stored is treated as text. Even if we store numbers, they are treated as text.
Text File Opening Modes
Below, we have discussed the different text file opening modes used to open a file.
| Mode | Description |
| r | Open file for reading only. |
| w | Open file for writing only. It creates the file if it does not exist. If the file exists, it erases all the contents of the file. |
| a | Open file for appending text. Text is added to the end of the file. It creates the file if it does not exist. |
| r+ | Open file for both reading and writing. |
| w+ | Open file for both reading and writing. It creates the file if it does not exist. If the file exists, it erases all the contents of the file. |
| a+ | Open file for reading and appending text. Text is added to the end of the file. It creates the file if it does not exist. |
Unlock This Lesson & Start Learning!
Get full access to this lesson, practical exercises, quizzes, and your Mentora AI Tutor.
Special Offer, use coupon code DWL6BC to get additional discount of 10% on all subscription. Hurry limited time offer.
1 Month
Renews at ₹259/month.
Manual renewal required.
No automatic charges.
- Premium lessons access
- Quizzes and exercises
- Mentora AI Tutor
3 Months
Equivalent to ₹219.67/month.
Manual renewal required.
No automatic charges.
- Premium lessons access
- Quizzes and exercises
- Mentora AI Tutor
6 Months
Equivalent to ₹193.17/month.
Manual renewal required.
No automatic charges.
- Premium lessons access
- Quizzes and exercises
- Mentora AI Tutor
12 Months
Equivalent to ₹179.92/month.
Manual renewal required.
No automatic charges.
- Premium lessons access
- Quizzes and exercises
- Mentora AI Tutor