Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdint.h>
- #include <stdlib.h>
- #include <errno.h>
- enum { BASE = 10 };
- int main(int argc, char *argv[]) {
- for (int i = 1; i < argc; ++i) {
- errno = 0;
- char* eptr;
- int64_t n = strtol(argv[i], &eptr, BASE);
- if (*eptr || errno) {
- printf("-1\n");
- } else {
- int8_t n8 = n;
- int16_t n16 = n;
- int32_t n32 = n;
- if (n8 == n) {
- printf("1\n");
- } else if (n16 == n) {
- printf("2\n");
- } else if (n32 == n) {
- printf("4\n");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement