Last active
May 31, 2024 18:48
-
-
Save hlord2000/37fb35955296d6a1df5bd9a661769721 to your computer and use it in GitHub Desktop.
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 <errno.h> | |
#include <string.h> | |
#include <stdlib.h> | |
int main(int argc, char *argv[]) { | |
if (argc != 2) { | |
fprintf(stderr, "Usage: %s <errno_value>\n", argv[0]); | |
return 1; | |
} | |
if (argv[1][0] == '-') { | |
argv[1]++; | |
} | |
int errno_value = atoi(argv[1]); | |
if (errno_value <= 0) { | |
fprintf(stderr, "Invalid errno value.\n"); | |
return 1; | |
} | |
printf("Errno %d: %s\n", errno_value, strerror(errno_value)); | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment