QP School
Handling errors and exceptions in C - Printable Version

+- QP School (https://qomplainerzschool.lima-city.de)
+-- Forum: Tutorials (https://qomplainerzschool.lima-city.de/forumdisplay.php?fid=3)
+--- Forum: C 18 Tutorials (https://qomplainerzschool.lima-city.de/forumdisplay.php?fid=32)
+--- Thread: Handling errors and exceptions in C (/showthread.php?tid=5106)



Handling errors and exceptions in C - Qomplainerz - 07-25-2023

Error handling involves dealing with unexpected or exceptional situations.

#include <stdio.h>
#include <errno.h>
#include <string.h>

int main() {
    FILE *file = fopen("non_existent_file.txt", "r");
    if (file == NULL) {
        printf("Error: %s\n", strerror(errno));
    }
    return 0;
}