Hello guys,
I am new in this forum and i hope im gonna get some fast help.
I have this problem where i should input numbers from a .doc file, and the program should output how many times the number of occurences of each number.
ie: the numbers in the .doc file are 2,3,6,8,9,2,1,1,3,1.
The program should read the numbers from the file and outputs the following:
Number 1 = 3
Number 2 = 1 ... and so on.
I started with the following but im getting stuck.
Any help please??
Code:
#include<iostream>
#include<fstream>
#include<iomanip>
using namespace std;
int main()
{
int array[10000];
int n;
ifstream numbers( "numbers.doc", ios::in);
if(!numbers)
{
cerr << endl << "File could not be opened" << endl;
system("pause");
exit(1);
}
for (int i=0, i<10000, i++)
array[i] = 0; //initializes array
for (i=0, i<50, i++)
{
if (i=1)
array[n] += array[i];
cout << array[i];
}
{
if (i=2)
array[n] += array[i];
cout << array[i];
}
results.close();
return 0;
}
///and so on.
My program is not working and i neeed someone please to help me fix it ASAP,
Thanks in advance.