I wrote this code to split a line containing words with many spaces and / or tab into a line vector containing only words.
1 #include<iostream>
2 #include<vector>
3 #include<boost/algorithm/string/split.hpp>
4 #include<boost/algorithm/string.hpp>
5 int main()
6 {
7 using namespace std;
8
9 string str("cONtainS SoMe CApiTaL WORDS");
10
11 vector<string> strVec;
12 using boost::is_any_of;
13
14 boost::algorithm::split(strVec, str, is_any_of("\t "));
15
16 vector<string>::iterator i ;
17
18 for(i = strVec.begin() ; i != strVec.end(); i++)
19 cout<<*i<<endl;
20
21 return 0;
22 }
23
I was expecting a way out
cONtainS
SoMe
CApiTaL
WORDS
but I get output with space as an element in strVec ie
cONtainS
SoMe
CApiTaL
WORDS
source
share