phone.c (423B)
1 /* Exercise 8.14 */ 2 3 #include <stdio.h> 4 #include <string.h> 5 #include <stdlib.h> 6 7 int main(void) 8 { 9 char phone[] = "(123) 456-78990", *tokp; 10 int prefix; 11 long int number; 12 13 tokp = strtok(phone, ")"); 14 prefix = atoi(++tokp); 15 16 tokp = strtok(NULL, "-"); 17 number = atoi( strcat(++tokp, strtok(NULL, " ")) ); 18 19 printf("Prefix: %d\n", prefix); 20 printf("Number: %ld\n", number); 21 22 return 0; 23 } /* E0F main */ 24