hi i am having trouble with a hw that uses arrays..the problem directiosn r.....
Write a program that counts occurances of each character in the input (128 ascii codes). Note this is different than counting classes (categories) of characters, because we want to know how many times each specific character appeared in the input. For control characters (those that are not printable) print the ascii code in angle brackets
so far i hav....
#include <iostream.h>
void initializeCountersToValue (int counterArray[], int value )
{
for (int i =0; i < 127; i++)
counterArray [i] = value;
}
void incrementCounterForCharacter (int counterArray [], char ch)
{
for (int i=0; i<127; i++)
if (counterArray [i] == ch )
counterArray [i]++;
}
void reportTotals ( int counterArray [])
{
for (int i = 0; i <127; i++)
cout << counterArray [i];
}
int main()
{
int characterArray[127];
initializeCountersToValue (characterArray, 0);
cout << "enter a bunch of text for counterin. /n";
cout << "type < ctrl-z> when done to indicate the end-of-file. /n";
for ( char ch; cin.get(ch)
incrementCounterForCharacter (characterArray, ch);
reportTotals (characterArray);
return 0;
}
itz not working ryte....so can neone help me figure out wat im doin wrong?