my program is suppose to count d number of occurrences of a chars in a file.
i just dont know how to store d occurences. this is wat i have done up to now.
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin;
void charactercount(int& w, char& s );
void main()
{
//int sum[128];
int w;
char s;
char charin;
char infile[20];
cout<< "enter file name"<< endl;
cin>> infile;
cout<<infile;
cout<< " " << endl;
fin.open(infile);
if ( fin.fail())
{
cout<< " cannot find file" << endl;
exit(0);
}
else
{
while(!fin.eof())
{
fin.get(charin);
w=static_cast<int>(charin);
s=static_cast<char>(w);
}
//here i think i have to make a for loop that compares the position of i (from 0 to 127) with the value of w and
// if they are equal add one to d occurrence of d position i
}}}
Thanks for reading it .
i hope u understand wat i mean.