My advice, use the vector container. One of the advantages of using C++.
bumsfeld
Nearly a Posting Virtuoso
1,445 posts since Jul 2005
Reputation Points: 404
Solved Threads: 184
#include <vector>
#include <boost/tokenizer.hpp>
#include <string>
#include <vector>
#include <iostream>
using namespace std;
using namespace boost;
int main()
{
string str = "The boost tokenizer library provides a flexible "
"and easy to use way to break of a string or other "
"character sequence into a series of tokens.\n"
"Here is a simple example that will break up a "
"paragraph into words.\n";
tokenizer<> toker( str );
vector<string> words( toker.begin(), toker.end() ) ;
cout << "there are " << words.size() << " words\n" ;
cout << "words[6]: " << words[6] << '\n' ;
}
vijayan121
Posting Virtuoso
1,606 posts since Dec 2006
Reputation Points: 1,159
Solved Threads: 287
What also complicates matters is if your words are separated by more than one space, or even tabs.
In that case, it would probably be wiser to use regular expressions. The task becomes almost trivial.
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439