i want to get token from string using string class. i know that using cstring, i can use strtok.can i use it?

#include <iostream>
#include <string>

using namespace std;
void echo(string message)
{
cout << message << endl;
}
int main()
{

cout << "Enter your word: ";
string word; // place declaration near its use
cin>>word
echo(word);

}

Look on your search engine of choice for 'stringstream'.

You can use CString's Tokenize() member function and loop through your source string retrieving the tokens into an array. Then you can access the individual tokens.

Nkamanyi Clement

Hey there, this is the second time in a row you are bumping an age old thread. Please see the date of the last post before posting new content. The OP is no longer interested in this topic.

Thread closed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.