How could I modify this program to output the tokens in reverse order?
I've tried numerous things which haven't worked. Is pointer arith needed? Thanks.Code:#include <iostream> using std::cin; using std::cout; #include <cstring> void output( const int, char [] ); int main() { const int Size = 50; char words[ Size ] = { '\0' }; cin.getline( words, Size ); output( Size, words ); cin.get(); return 0; } void output( const int Size, char sentence[] ) { char *strToken; int control = Size; strToken = strtok( sentence, " " ); cout << '\n'; while ( (strToken != NULL) ) { cout << strToken << '\n'; strToken = strtok( NULL, " " ); } }



LinkBack URL
About LinkBacks


