/* p11b.c */ /* Demonstrates how to acquire numeric data from lines of input that look like: XX 1 2 4 XX 33 55 XX 66 67 68 */ #include #include #include main() { unsigned char *buf; int line = 0; unsigned char *start; unsigned char *stop; int val; buf = (unsigned char *)malloc(1024); if (buf == 0) exit(1); while (fgets(buf, 1024, stdin) != 0) { stop = buf + 3; /* or start = &buf[3] */ do { start = stop; val = strtol(start, (char **)&stop, 0); if (start != stop) printf("%5d \n", val); } while (start != stop); } }