| 1 | #include <stdio.h> |
| 2 | |
| 3 | |
| 4 | /******* |
| 5 | * getargs(s, arps) |
| 6 | * char *s, *arps[]; |
| 7 | * |
| 8 | * getargs - this routine will generate a vector of |
| 9 | * pointers (arps) to the substrings in string "s". |
| 10 | * Each substring is separated by blanks and/or tabs. |
| 11 | * |
| 12 | * return - the number of subfields. |
| 13 | */ |
| 14 | |
| 15 | getargs(s, arps) |
| 16 | char *s, *arps[]; |
| 17 | { |
| 18 | int i; |
| 19 | |
| 20 | i = 0; |
| 21 | while (1) { |
| 22 | arps[i] = NULL; |
| 23 | while (*s == ' ' || *s == '\t') |
| 24 | *s++ = '\0'; |
| 25 | if (*s == '\n') |
| 26 | *s = '\0'; |
| 27 | if (*s == '\0') |
| 28 | break; |
| 29 | arps[i++] = s++; |
| 30 | while (*s != '\0' && *s != ' ' |
| 31 | && *s != '\t' && *s != '\n') |
| 32 | s++; |
| 33 | } |
| 34 | return(i); |
| 35 | } |