Can any 1 help me or give me a tip
i know that i have some mistakes
what I want to do is :
- Read the input until eof keeping track of each letter that occurs in the input as well as the number of occurrences of that letter.
- Sort the letter counts from largest to smallest. in the array
** i think we are using parallel Array to make the sorting.
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
//functions
void searchingSimiler ( char letters[], int counts[], int update, char newletter );
int main()
{
string filename, item;
char letters[26], newletter;
int counts[26];
int count=0;
cout << "Please enter the name of the file to process: ";
cin >> filename;
ifstream ins;
ins.open(filename.c_str());
if (ins.fail())
{
cout << "Sorry, that file does not exist ... ending program ..\n";
exit(1);
}
while ( ins >> item )
{
for ( int i=0 ; i < item.length() ; i++)
{
if ( isalpha(item[i]))
newletter = item[i];
searchingSimiler(i,i,i,item[i]);
}
}
cout << count << endl;
return 0 ;
}
void searchingSimiler ( char letters[], int counts[], int updatenew[], char newletter )
{
for ( int j=0 ; j < letters[j] ; j++ )
if ( letters[j] == newletter )
{
updatenew++;
counts[j] = updatenew[j];
}
else
{
letters[j+1] = newletter;
counts[j+1]++;
}
}