int main() { //*********************************** //Variable Declarations //*********************************** const int NUM_STUDENTS = 5; const int NUM_SCORES = 4; double studentScores[NUM_STUDENTS][NUM_SCORES]; string name[NUM_STUDENTS]; int ID[NUM_STUDENTS]; int row = 0, record = 0, line = 0; double testScores = 0.0; string input = "Student Data.txt"; fstream fin; stringstream ss; fin.open( input.c_str() ); if (fin) { getline(fin, input); while (fin) { for( int record = 0; record < NUM_STUDENTS; record++ ) { for (line = 0; line < 2; line++) { if (line == 0) { name[line] = input; // cout << "Line " << line << "\n\n"; cout << name[line] << endl; } if (line == 1) { cout << "Line " << line << "\n\n"; ID[line] = atoi(input.c_str()); stringstream ss(input); cout << ID[line] << endl; } if (line == 2) { cout << "Line " << line << "\n\n"; ss << input; for( int col = 0; col < NUM_SCORES; col++ ) { stringstream ss(input); ss >> testScores; studentScores[row][col] = testScores; ss << ""; } } } } // cout << input << endl; getline(fin, input); } fin.close(); } else { cout << "ERROR: Cannot open file. \n"; } } |