Skip to content

Instantly share code, notes, and snippets.

@jsteemann
Created February 7, 2013 23:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsteemann/4735049 to your computer and use it in GitHub Desktop.
Save jsteemann/4735049 to your computer and use it in GitHub Desktop.
small helper program to print the error messages for integer system error codes. use as follows: ./dumperror <code>
/*
small helper program to print the error messages for
integer error codes. use as follows:
gcc -Wall -Wextra -pedantic dumperror.c
./dumperror <code>
where code is the error number you're interested in
*/
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
int main (int argc, char* argv[]) {
int code;
if (argc != 2) {
fprintf(stderr, "usage %s <code>\n", argv[0]);
exit(1);
}
code = (int) atoi(argv[1]);
printf("%s\n", strerror(code));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment