hi, I can't understand how use it:
I have 3 files to open and read. In temp_str goes the right string only when i=0; other times when I=1,2 temp_str take nothing. It works all with *(fIter[0]) >> temp_str;Code:string temp_str; vector <fstream*> file; for (int i=0; i < 2; i++) { fstream* ff = new fstream; *ff << i.toString(); //pseudo-code file.push_back(ff); ff->close(); } // now the files are filled with two different strings ---- MY problem begin here... vector <fstream*>::iterator fIter; int i; for (fIter = file.begin(), i=0; fIter != file.end(); ++fIter, i++) { (*fIter)->open(computeFileName(i).c_str(), ios_base::in); *(fIter[i]) >> temp_str; //*(fIter[0]) >> temp_str; //with this, it works! why? }
Anyone could explain me how understand this vector??
thanks