I am trying to take input from a text file containing 1000 records.
- 10
- 1 100
- 2 101
- 3 123
- 4 124
- .
- .
- .
- 1000 1234
I am using the code below to take the input in three variables d=10 (first line of the text file, a contains all the numbers in first column and b contains all the numbers in second column.
The problem I am facing with this code is it takes the last half of the file as input the first half is ignored.
output:
- 500 3211
- 501 3212
- 502 22121
- .
- .
- .
1000 1234
char fileName[20]; cout << "Enter input test file name: "; cin >> fileName; ifstream readFile; //object of input file stream readFile.open(fileName); //open a file //Check for an error if (readFile.fail()) { cerr << "Error Opening File" << endl; } string c, d,a,b; getline(readFile, c); for (int i=0; i<1000;i++) { getline(readFile, readLine); istringstream split(readLine); getline(split, a); getline(split, b); cout <<serverNum<<" "<<a<<" "<<b<<endl; }
can someone suggest me why am I facing this