Hi,
I have a string array. In this string array for example if i get teststring[0] out it returns me "this is a test string".
with this string its delimited by white spaces. But i am having trouble to delimit them into "this" "is" "a" "test" "string".
i tried using the following codes but char mystring[a] does not accept in the string returned from teststring[0].
Code:
string a = teststring[0];
char mystring[] = a;
char *delim = " "; // only blank
char *token;
token = strtok(mystring, delim);
while (token !=NULL)
{
//compare ... (strcmp (token,"and") )
//continue loop if equal
string s = token;
token = strtok(NULL,delim);
cout << "the string token is " << s<<endl;
}
Is there any other better way to delimit the strings in my string array?? please help beeen figuring this for long but cant seem to find a solution...