CSC209H1 Chapter Notes - Chapter 6: Errno.H, Global Variable, Entry Point
Document Summary
Errors and errno video 1: when system calls fail show_fopen show_malloc getsize getsize_bad. Errno is a global variable of type int. The message includes the argument s followed by a colon and then the error message that corresponds to the current value of errno. Don"t use perror as a generic error message reporting function. Real purpose is to display an error message based on the current value of errno. For other types of error messages, should still use fprintf to stderr. Return in other functions will not terminate the program. Exit always terminate the program whenever it executes. Checking fgets() is able to read any data from the file: If can"t, that"s not an error that will set errno. It simply signals the end of the file. Should have checked argc and argv before the fopen() Will have this one more line of ":undefined error: 0" since fgets() did not actually fail.