
5 Dec
2011
5 Dec
'11
12:49 p.m.
I noticed the below crashes[run time error because of space in string] Is there a possibility to handle this situation? [without explicitly calling split]
string s = " 12252001"; int offsets[] = {5,2,4}; offset_separator f(offsets, offsets+3); tokenizer
tok(s,f); for(tokenizer ::iterator beg=tok.begin(); beg!=tok.end();++beg) int val = boost::lexical_cast<int>( *beg);
You should explicitly trim every token (use boost/algorithm/string/trim.hpp). Alternatively, you could use more flexible facility, like Spirit.