/* * Program to print command-line arguments and say which ones can be * converted to integers and floating point. */ #include #include int main(int argc, char * argv[]) { for (int i = 0; i < argc; ++i) { printf("arg %d is %s\n", i, argv[i]); char *endptr; long n = strtol(argv[i], &endptr, 10); if (*endptr == '\0') { printf("arg %d is integer %ld\n", i, n); } double d = strtod(argv[i], &endptr); if (*endptr == '\0') { printf("arg %d is floating point %f\n", i, d); } } return 0; }