C errors/exceptions
From wikinotes
system errors (errno/perror)
When syscalls produce errors, they return -1, and set the global constant errno. <errno.h>'s perror is a function that when provided with an errno, returns the error that was produced.
Seeman errno
for a list ofexit()
codes and their meanings.
#include <errno.h> void error( const char *message ){ if (errno) { perror( message ); } else { printf("ERROR: %s\n", message); exit(1); } }
exceptions
C does not have any exceptions.