Problem is described here. I tried to solve it using code that's below, but it's not working.
const char* filename = "test.txt";
ifstream file1(filename);
vector<int> v1;
vector<int> v2;
vector<int> res;
int number;
char c;
while(1){
while(1){
v1.push_back(number);
file1.get(c);
if (c==';') break;
}
while(1){
v2.push_back(number);
file1.get(c);
if (c=='\n') break;
}
for (vector<int>::iterator it = v2.begin(); it!=v2.end(); it++)
cout << *it << ',';
cout << endl;
file1.get(c);
if (c==EOF) break;
file1.unget();
}
There is a problem with reading end of line. Is c=='\n' right?
Aucun commentaire:
Enregistrer un commentaire