File Handling in C
C provides file handling functions through the stdio.h header.
Common functions include:
- fopen()
- fclose()
- fprintf()
- fscanf()
- fgets()
- fputs()
Opening a File
FILE *file = fopen("data.txt", "w");
Common file modes include:
- r — read
- w — write
- a — append
Always check whether fopen() successfully opened the file.