Need help

Input: A file contains up to 200 test scores ranging in value from 0 to 100; the last entry in the
file is a sentinel value of -999. Output: In an output file, list scores sorted in increasing order;
next to each score is the count of how many times that score appeared in the input. Use the
format shown below:
Test Scores Count
53 1
55 3

This is what I have so far it outputs "testscores" and "count" but no values.
#include <iostream>
#include <fstream>

using namespace std;

int main()
{
ifstream infile;
ofstream outfile;

infile.open("program2input.txt");
outfile.open("program2outfile.txt");

int counter[101];
int index;
int value;



infile >> value;

while (value != -999)
{
counter[value]++;
infile >> value;

}
outfile << "testscores" << " " << "count" << endl;
for (index = 0; index <= 100; index++)

if (counter[index] > 0)
outfile << index<< counter[index] << endl;



system("pause");
return 0;
}
Topic archived. No new replies allowed.