Hello, I am trying to read from a text file and this is what I have so far.
The text file looks like this but longer.
0 111111112 15 155
1 1111 4 A
1 1112 4 B
1 1113 3 C
0 111111111 30 90
1 1111 4 A
1 1112 3 A
0 stands for student followed by its ssn and 2 other variables that I must do math with.
1 stands for class followed by the class number, credit hours, and the grade in the course. The grade must be converted into a number A = 4, B = 3, C = 2, D = 1, F = 0.
I keep getting a infinate loop even though I used the &&1 in my while loop. Any ideas?
The text file looks like this but longer.
0 111111112 15 155
1 1111 4 A
1 1112 4 B
1 1113 3 C
0 111111111 30 90
1 1111 4 A
1 1112 3 A
0 stands for student followed by its ssn and 2 other variables that I must do math with.
1 stands for class followed by the class number, credit hours, and the grade in the course. The grade must be converted into a number A = 4, B = 3, C = 2, D = 1, F = 0.
I keep getting a infinate loop even though I used the &&1 in my while loop. Any ideas?
Code:
#include <iostream> #include <iomanip> #include <fstream> using namespace std; int main() { //startMain ifstream indata; int ssn, grdLvl, cre, pts, gpa, impr; indata.open ("/home/lx/abyrnes/input/cs241/fall07/pgm1.txt"); if (indata.fail()) { cout <<"\nFILE IS MISSING!"; exit(1); } indata >> ssn >> grdLvl >> cre >> pts >> gpa >> impr; while ( !indata.eof() && 1 ) { cout << "Test: " <<ssn << " " << grdLvl << " " << cre << " " << pts << " " << gpa << " " << impr; indata >> ssn >> grdLvl >> cre >> pts >> gpa >> impr; } indata.close(); } //endMain
Comment