Add errno-printing program
authorColin McCabe <cmccabe@alumni.cmu.edu>
Sun, 13 Dec 2009 23:27:54 +0000 (15:27 -0800)
committerColin McCabe <cmccabe@alumni.cmu.edu>
Sun, 13 Dec 2009 23:27:54 +0000 (15:27 -0800)
errno_speak.c [new file with mode: 0644]

diff --git a/errno_speak.c b/errno_speak.c
new file mode 100644 (file)
index 0000000..832ebe3
--- /dev/null
@@ -0,0 +1,23 @@
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+/*
+ * This program takes an errno number as input, and prints out a long
+ * description of the error, using strerror.
+ *
+ * Colin McCabe
+ */
+
+int main(int argc, char **argv)
+{
+    int err;
+    if (argc != 2) {
+        printf("usage: %s [errno number]\n", __func__);
+        return 1;
+    }
+    err = atoi(argv[1]);
+    printf("errno %d: %s\n", err, strerror(err));
+    return 0;
+}
+