c++ - Re-setting an istringstream object -


when run code:

for (int = 0; < indexarray.size(); i++) {                  iss.str(indexarray.at(i));                 iss>>one;                 iss>>two;                 iss>>three;                 cout<<one<<" "<<two<<" "<<" "<<three<<" "<<"\n"; } 

the istreamstream (iss) remains same every iteration. (the file read vector @ beginning of program. yes, checked make sure array had corresponding data.)

in other words, output:

12345 1  0  12345 1  0  12345 1  0  

whereas file/vector says:

12345 1 0 12346 1 25 12543 1 50 

i've tried various traces , can't pinpoint problem. thanks!

you should call iss.clear(); before iss.str(indexarray.at(i)); clear eof flag when reusing istringstream.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -