I think I'm on the right track, basically trying to count the number of tokens but it keeps telling me cannot convert to a const.
//This program is made to count the number of words.
#include <iostream>
using namespace std;
#include <cstring>
int wordCount(char *);
int main()
{
char checkCount[20];
cout << "Enter a sentence: " ;
cin.getline(checkCount, 21, '\n');
cout << "The sentence has " << wordCount(checkCount) << " word." << endl;
return 0;
}
int wordCount(char yourSentence)
{
int count = 0;
char* tokenPtr;
tokenPtr = yourSentencetok(yourSentence, " ");
while (tokenPtr!='NULL')
{
count++;
}
return count;
}