C Programming – Day 10 | File Handling in C Explained for Beginners
FILE HANDLING IN C
DAY - 10
✅ Let’s move to Day-10 — File Handling in C 🚀
📍 Day-10 — File Handling in C
Today we will learn:
✅ What is a file?
✅ Types of files in C
✅ File operations: open, read, write, close
✅ Reading and writing text files
✅ Task + Quiz
✅ 1️⃣ What is a File?
📌 A file is a collection of data stored on disk
📌 C allows programs to read/write files
Types:
-
Text File →
.txt(Human-readable) -
Binary File →
.bin(Computer-readable)
✅ 2️⃣ File Operations in C
1️⃣ Open a file → fopen()
2️⃣ Write to a file → fprintf() or fputs()
3️⃣ Read from a file → fscanf() or fgets()
4️⃣ Close the file → fclose()
✅ 3️⃣ Example — Write & Read File
✅ 4️⃣ File Modes in C
| Mode | Meaning |
|---|---|
| r | Read only |
| w | Write only (overwrite) |
| a | Append |
| r+ | Read & write |
| w+ | Write & read (overwrite) |
| a+ | Append & read |
✅ Task-10
Write a program:
✔ Create a file marks.txt
✔ Input marks of 3 students
✔ Write marks to file
✔ Read from the file and display on screen
Example Output:
📌 Hint: Use fprintf() for writing and fscanf() or fgets() for reading
📝 Quick Quiz — Day-10
Reply like: 1C, 2B, 3A
1️⃣ Function to open a file:
A) fopenfile()
B) open()
C) fopen()
2️⃣ Mode to append text to a file:
A) w
B) a
C) r
3️⃣ Function to close a file:
A) fclose()
B) closefile()
C) endfile()
📌 Reminder:
Send your Task-10 Code and Day-10 Quiz Answers when ready!
Then we will proceed to Day-11: Dynamic Memory Allocation in C 💪

No comments
Thank You For Visit My Website.
I Will Contact As Soon As Possible.