How to count the letters?

I'm just trying to find out if the way I've setup my code currently allows me to count the letters as they occur?

I don't yet see how to do it but I need clarification. Also would be nice if someone told me if I were on the right track or not. Ideally the function letterCounter would do the counting but atm I'm just trying to figuring it out in the display function.

Code Erased.
Last edited on
Ok so this code works it seems.

1
2
3
4
5
6
7
8
int counter[500]={0};
	for (int i=0;i<26;i++) {
	char letter = letterArray[i];
	for (int k=0;k<26;k++) {
	if((letterArray[k])==letter) counter[i]++ ;
}
cout<<letter<<" = "<<counter[i]<<" time(s)."<<endl;
}


My only problem is that the letterArray is as it is when its first created in createAbc. The randomly selected characters from the display function are apparently exclusive to the display function (maybe the for loop?). If I can figure out how to transfer the random characters chosen in Display to letterCounter I should be in business right?
This seems to count correctly but because its in the for loop restricted by numChar it just displays the the count next to the random letters itself. Anyone have any ideas?
Code Erased

EDIT: I just had to declare the counter array per function instead of just in one function.
Last edited on
Topic archived. No new replies allowed.