c++11 - Variable not printing on iteration -


i'm writing c++ csv class personal project, have stumbled on weird error. in test program have code:

for( int = 0; < 3; ++i ) {     std::cout << << ": ";     std::vector<std::string> results = test.get_row();     for( auto = results.begin(); != results.end(); ++it ) {         std::cout << *it << " ";     }     std::cout << std::endl; } 

and results:

 : row0 row1 row2  : blah0 blah1 blah2 2: blah3 blah4 blah5 

but should getting:

0: row0 row1 row2 1: blah0 blah1 blah2 2: blah3 blah4 blah5 

any ideas why i'm not getting i value on first 2 runs?

note: i'm using g++ 4.4.7

ah. think see it:

you appear have forgotten strip newlines input.

this resulting in last column having trailing '\r', , since always add ' ', space overwrite printed i.

strip newline character input before splitting columns values :)


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -