Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- char* reverseAllWords(char str[])
- {
- char * pch;
- char *listWord[100];
- char result[100]="";
- int index=0;
- pch = strtok (str," ");
- while (pch != NULL)
- {
- listWord[index] = pch;
- pch = strtok (NULL, " ");
- ++index;
- }
- int i;
- for (i=index-1; i>=0; --i)
- {
- strcat(result,listWord[i]);
- strcat(result," ");
- printf("",result);//magic line
- }
- return result;
- }
- int main ()
- {
- char str[100] ;
- gets(str);
- printf("%s",reverseAllWords(str));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement