Hello,
I am trying to understand how to use C-style strings in C++. My goal is to store a C-style strings into a string type array.
If I pass "This is a test" into word_token, it displays:
This
Is
A
test
So from here I believe my setup is almost right, I'm just having problems passing these into a string type array
Does not print out "This" as I expect it too
myArray[*token] ;
cout << myArray[0] ;
void word_token(char *str){
string myArray[256]; // assuming str <= 256 words
char spaces[] = " "; // deliminator
char *token = strtok(str, spaces); // creates token when a space is found
while (token){
cout << token << endl;
toke = strtok(NULL, spaces);
//myArray[*token]; //this does not work*
//cout << myArray[0];
}