I need help to modify a program so that it will work with a datafile \"scores2.d
ID: 3534414 • Letter: I
Question
I need help to modify a program so that it will work with a datafile "scores2.dat" that has less than 1000 numbers(grades). You'll use the technique of partially filled arrays. Output the number of values read in addition to another datafile called "scores.dat". Do not count manually and hard code your program for that many values.
#include <iostream>
using namespace std;
#include <fstream>
int main()
{
ifstream fin; //file stream variable
int num;
fin.open("../datafile.dat);
if (!fin)
{
cout << "Error opening file. ";
return 1;
}
cout << "Numbers ";
while (fin >> num)
{
cout << num << endl; //output num read
// this is where you would put the code to store num in your array
// thsi is where you would put a counter to count the items read too
}
fin.close();
return 0;
}
Explanation / Answer
//not sure what your last sentence meant, but this reads in scores2.dat: http://ideone.com/uUcaMY
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.