I have written up a c++ program that will read from a file. The file consists of only numbers ( from 1 to 50) and spaces with no other special characters. The main aim of the program is to tell me how many times the numbers appeared in the file but whenever i run my program it always hangs. Any help is appreciated.
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
int num;
int A[50];
ifstream infile;
for (int i = 0; i < 50; i++)
A = 0;
infile.open("Numbers.txt");
infile >> num;
while (!infile.eof())
{
for (int j = 0; j < 50; j++)
{
if (num == j)
A[j] = A[j] + 1;
}
infile >> num;
}
for (int k = 0; k < 50 ; k++)
cout << k <<" appeared " <<A[k] << " times " << endl;
}