Created
January 13, 2013 10:51
-
-
Save flatmap13/4523512 to your computer and use it in GitHub Desktop.
Small command line application to translate error numbers to readable messages.
You can supply multiple error numbers via command line arguments. If zero arguments are supplied, the app asks for an error number interactively.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
void print_error(int); | |
int main(int argc, char *argv[]) | |
{ | |
int err_num; | |
if(argc > 1) { | |
while(--argc > 0 && ++argv) { | |
if(err_num = atoi(*argv)) | |
print_error(err_num); | |
else | |
printf("warning: '%s' is not a valid error number\n", *argv); | |
} | |
} else { | |
printf("input error code: "); | |
scanf("%d", &err_num); | |
print_error(err_num); | |
} | |
return 0; | |
} | |
void print_error(int err_num) | |
{ | |
printf("%d: %s\n", err_num, strerror(err_num)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment