hi; i need to count d number of occurrences of all the chars in a file. i can't figure out how to count how many of each char there are. this wat i have up to now.
i need the to print only the ASCII code from 0-127
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin;
void count(int & w );
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);
cout<< charin;
w=static_cast<int>(charin);
s=static_cast<char>(w);
cout<< "= "<<w<<" ";
void count ( int & w);
{ for (int i=0; i<128 ; i++);
{
if(w==i)
{
sum[i]++;
}
}
}
}
}
}