int main (void) { int errn; int errnmax; const char *name; const char *msg; char *strerror (); errnmax = errno_max (); printf ("%d entries in names table.\n", num_error_names); printf ("%d entries in messages table.\n", sys_nerr); printf ("%d is max useful index.\n", errnmax); /* Keep printing values until we get to the end of *both* tables, not *either* table. Note that knowing the maximum useful index does *not* relieve us of the responsibility of testing the return pointer for NULL. */ for (errn = 0; errn <= errnmax; errn++) { name = strerrno (errn); name = (name == NULL) ? "<NULL>" : name; msg = strerror (errn); msg = (msg == NULL) ? "<NULL>" : msg; printf ("%-4d%-18s%s\n", errn, name, msg); } return 0; }
int main (void) { int em = errno_max(); printf("Nothing can go more wrong than %d\n", em); printf("ToolChain says the answer is %d\n", the_answer_is()); return 0; }