Error Handling
Check return values. errno and perror describe failures.
Example
#include <stdio.h>
int main(void) {
FILE *f = fopen("/no/such/file", "r");
if (!f) { printf("open failed\n"); return 0; }
fclose(f);
return 0;
}Result
open failed
Exercise
Describe an error.
("open")Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.