This demonstrates how to work with the eaarlio_error values returned by most library functions.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[])
{
int i;
int failed;
if(argc < 2 || 0 == strncmp(argv[1], "-h", 3) || 0 == strncmp(argv[1], "--help", 7)) {
printf("Usage: example_errors [-h] <code> [<code> ...]\n");
printf("Example of interpreting error codes\n");
printf("\n");
printf(" -h, --help display this help and exit\n");
printf(" <code> an integer value representing an error code\n");
return 1;
}
for(i = 1; i < argc; i++) {
printf("---\nTest value %d: %s\n\n", i, argv[i]);
printf("Success\n\n");
} else {
printf("Failure\n\n");
}
printf("\n");
if(!failed) {
printf("Success\n");
}
printf("\n");
}
return 0;
}