#include #include #include int main(int argc, char **argv) { int i; if (argc<3) { printf("usage: %s \n" "Uninitialized variables have value of -777, -7.77, or \"BAAD\"\n", argv[0]); return 0; } for(i=1; i returned %d, results %s=%d remainder=\"%s\"\n", str, fmtbuffer, type, status, type, ival, remainder); } break; case 'f': status = sscanf(str, fmtbuffer, &fval, &remainder); if (status < 0) { perror("Error: sscanf returned 0\n"); } else { printf("sscanf(\"%s\", \"%s\", &%s, &remainder) -> returned %d, results %s=%f remainder=\"%s\"\n", str, fmtbuffer, type, status, type, fval, remainder); } break; case 'd': case 'l': status = sscanf(str, fmtbuffer, &dval, &remainder); if (status < 0) { perror("Error: sscanf returned 0\n"); } else { printf("sscanf(\"%s\", \"%s\", &%s, &remainder) -> returned %d, results %s=%f remainder=\"%s\"\n", str, fmtbuffer, type, status, type, dval, remainder); } break; case 'c': status = sscanf(str, fmtbuffer, &cval, &remainder); if (status < 0) { perror("Error: sscanf returned 0\n"); } else { printf("(%d) %s -> %c \"%s\"\n", status, str, cval, remainder); } break; default: printf("Unknown type: %s\n", type); break; } } }