strtok_rev.c (481B)
1 /* Exercise 8.15 */ 2 3 #include <stdio.h> 4 #include <string.h> 5 6 #define SIZE 254 7 8 void strtok_rev(char *s); 9 10 int main(void) 11 { 12 char string[SIZE], *c; 13 14 printf("Give me a string: "); 15 gets(string); 16 17 c = strtok(string, " "); 18 strtok_rev(string); 19 printf("%s\n", c); 20 21 return 0; 22 } /* E0F main */ 23 24 void strtok_rev(char *s) 25 { 26 char *tokp; 27 28 tokp = strtok(NULL, " "); 29 30 if(tokp != NULL) { 31 strtok_rev(s); 32 printf("%s ", tokp); 33 } 34 35 } /* eof strtok_rev() */ 36