I am using this function to get data from a file
where 'one' is a struct with three int variables a, b, c.
The file is of the form
1 12 14
2 1 1
3 1 1
4 13 1
6 1 12
6 1 04
When I output this data, the output is of the form
2 1 1
3 1 1
4 13 1
6 1 12
6 1 04
That is the first line is not read properly, but the other lines come out fine. Could anyone please let me know the problem?
Code:
void get() { string line; ifstream myfile; myfile.open ("jty.txt"); while (getline(myfile, line)) { myfile >> one[i].a >> one[i].b >> one[i].c; i++; } myfile.close(); }
The file is of the form
1 12 14
2 1 1
3 1 1
4 13 1
6 1 12
6 1 04
When I output this data, the output is of the form
2 1 1
3 1 1
4 13 1
6 1 12
6 1 04
That is the first line is not read properly, but the other lines come out fine. Could anyone please let me know the problem?
Comment