I'm trying to use the function strtok to tokenize an input from the user and then print out the result with new lines between each word. However, this error pops up.
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
int main()
{
string str;
char *tokenPtr;
cout << "Enter a sentence : " << endl;
getline(cin, str);
tokenPtr = strtok( str, " " ); // ERROR: No matching function for call to 'strtok'
while( tokenPtr != NULL ) {
cout << tokenPtr << endl;
tokenPtr = strtok( NULL, " " );
}
return 0;
}