Not checking return values 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: Not checking return values in C (/showthread.php?tid=5122) |
Not checking return values in C - Qomplainerz - 07-26-2023 Neglecting to check the return values of functions that can fail (e.g., malloc, fopen, etc.) can lead to errors. // Incorrect FILE *file = fopen("non_existent_file.txt", "r"); // No check for the success of fopen() // Correct FILE *file = fopen("non_existent_file.txt", "r"); if (file == NULL) { // Handle error (file not opened) } |