Nearby lessons
72 of 72C - Append to a File
Appending means adding new information to the end of a file while keeping the existing content. Learn how to use the "a" mode with fopen().
1. Append Data Using a Mode
Open the file with "a" and write the new content. Existing data stays in the file.
Example01
2. Difference Between w and a
| Mode | Result |
|---|---|
w | Creates a missing file or erases existing contents. |
a | Creates a missing file or adds new content at the end. |
Example02
3. Common Uses of Append Mode
Append mode is useful for log files, activity records, simple journals, and adding new entries to a text file without deleting earlier entries.
📝 Key Takeaways
- The a mode adds new data at the end of a file.
- Existing content is kept when using a mode.
- If the file does not exist, a mode creates it.
- The w mode replaces old content, while a mode preserves it.
🧠 Test Your Knowledge
3 QuestionsProgress: 0 / 3