dataconv.c (955B)
1 /* Exercise 8.36 */ 2 3 #include <stdio.h> 4 #include <string.h> 5 #include <stdlib.h> 6 7 int main(void) 8 { 9 char data[11] = { 0 }, *tokp; 10 11 printf("Insert data: "); 12 gets(data); 13 14 tokp = strtok(data, "/"); 15 printf("%d ", atoi(tokp)); 16 17 tokp = strtok(NULL, "/"); 18 19 switch(atoi(tokp)) { 20 case 1: 21 printf("January"); 22 break; 23 case 2: 24 printf("February"); 25 break; 26 case 3: 27 printf("March"); 28 break; 29 case 4: 30 printf("April"); 31 break; 32 case 5: 33 printf("Maj"); 34 break; 35 case 6: 36 printf("June"); 37 break; 38 case 7: 39 printf("July"); 40 break; 41 case 8: 42 printf("August"); 43 break; 44 case 9: 45 printf("September"); 46 break; 47 case 10: 48 printf("October"); 49 break; 50 case 11: 51 printf("November"); 52 break; 53 case 12: 54 printf("December"); 55 break; 56 default: 57 printf("Unknown month"); 58 } 59 60 tokp = strtok(NULL, "/"); 61 printf(" 19%d\n", atoi(tokp)); 62 63 return 0; 64 } /* E0F main */ 65