Here is what i have so far...this will take a users input string and take each word as a token and output on seperate lines. IE. "Hello" World outputs
Hello
World
I need to reverse this output ie
World
Hello
Here is my code:
#include <stdio.h>
#include <string.h>
int main ()
{
char string[100] = " ";
char *tokenPtr;
printf( "Enter a line of text up to 100 character in length:\n"
gets(string);
printf("%s\n%s\n\n%s\n",
"The String to be tokenized is:", string,
"The Tokens are:" );
tokenPtr = strtok( string, " " );
while ( tokenPtr != NULL ) {
printf( "%s\n", tokenPtr );
tokenPtr = strtok( NULL, " " );
}
return 0;
}
Hello
World
I need to reverse this output ie
World
Hello
Here is my code:
#include <stdio.h>
#include <string.h>
int main ()
{
char string[100] = " ";
char *tokenPtr;
printf( "Enter a line of text up to 100 character in length:\n"
gets(string);
printf("%s\n%s\n\n%s\n",
"The String to be tokenized is:", string,
"The Tokens are:" );
tokenPtr = strtok( string, " " );
while ( tokenPtr != NULL ) {
printf( "%s\n", tokenPtr );
tokenPtr = strtok( NULL, " " );
}
return 0;
}