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]++;
		}
}
void searchingSimiler ( char letters[], int counts[], [B]int updatenew[],[/B] char newletter )

What is updatenew anyway? I recommend replacing it with a variable called letterarrcount (or whatever) which you pass in by reference. j < letters[j] -- this is completely wrong -- I would use letterarrcount in it's place.

else
{
   letters[j+1] = newletter;
   counts[j+1]++;
}

You surely don't want to do this each time you go through the loop. Finish out the loop and check if you've gone through all the letters, then add a new one.

Check the parameters you are passing into your function too, though wait until after all your changes.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.