Opening and Closing Files in C — a practical guide to C fopen fclose with clear examples you can reuse in real projects.
C Programming Tutorial Series (74/102). Prefer one article? Read the complete C programming tutorial.
Short description
Modes include "r", "w", "a", and binary variants like "rb".
fopen/fclose
FILE *fp = fopen("data.txt", "r");
if (!fp) {
perror("fopen");
return 1;
}
fclose(fp);