Again, I am stuck! (last part of my program, thank god) I need to read just two lines of my file of integers. I thought the following code would work, however, I am once again wrong and at a loss. Tell me WHY it doesn't work and if there is a different way I should be approaching it. Please keep in mind that I am trying to learn and a beginner.
Code:inFile.open ("K:\\DATFILE1.TXT"); if ( !inFile ) { cout<< "**Can't open input file**" <<endl; return 1; } sum = 0; count = 0; numCount = 0; while (inFile && (count < 3)) { inFile >> num; numCount++; sum = sum + num; count++; } average = sum / numCount; outFile << fixed << setprecision(3) << "The average of the first two lines of the file is " << average <<"." <<endl; inFile.close(); inFile.clear();