Subj : A funny thing.. To : All From : Bo Simonsen Date : Tue Apr 20 2010 23:10:06 Hi everybody... I had one of these bugs today where you really wanted to say "doh".. I've this nice line splitting routine: -------------- C++ code -------------- void SplitLine(string s, vector& l, char delim, int times) { string::size_type i = 0; string::size_type last = 0; bool ignore = false; while(i < s.size()) { if(s[i] == '"') { if(!ignore) { ignore = true; last = i + 1; } else { string new_str = s.substr(last, i-last); l.push_back(new_str); last = i + 2; i += 2; ignore = false; } } else if(s[i] == delim && !ignore) { string new_str = s.substr(last, i - last); l.push_back(new_str); last = i; last++; } ++i; if(times > 0 && static_cast(l.size()) >= times) { break; } } if(s.size() - last > 0) { cout << last << " " << s.size() << endl; string new_str = s.substr(last, s.size() - last); l.push_back(new_str); } } ---------------------------- The problem is that this code does not work, since the last if-block is invoked at times where it should not be invoked. Can anybody see why? :-) Bo (I'll post the solution in a couple of days if I get no response :)) --- DayDream BBS/UNIX (Linux) 2.15 * Origin: The Night Express BBS, Copenhagen, nightexp.no-ip.org (2:236/100) .