QP School

Full Version: Handling errors and exceptions in C
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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;
}