OK Can anyone help me understand what a tokenizer does? And why I have to put *tokenPtr? What is the * for?
I am having a heck of a time figuring out how to write a program that takes the last two letters of a word in a sentence puts them on the front of a new word and adds 'ay' to the end of the word then moves to the next word in the sentence and starts over. It is an online class so I can't ask the teacher for help in class and the assignment is due tomorrow. I have some sample code from the book but it isn't helping me. The following is my start.
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
#include <cstring>
using std::strtok;
using std::strlen;
const int SIZE = 80;
// function prototype
void printLatinWord( const char *token );
int main()
{
char sentence[ SIZE ];
char *tokenPtr;
cout << "Enter a sentence:\n";
cin >> sentence;
*tokenPtr = strtok( sentence, " " );
while ( *tokenPtr != NULL )
{
printLatinWord( *tokenPtr )
*tokenPtr = strtok( NULL, " " );//get next token
}
return 0;
}
void printLatinWord ( const char *token )
{
cout << strlen( token );
}
Thanks for any help!:?: