Im trying to verify predetermined char in random array so i can know if some of the three char appear three times or more.
i would probably write a function that will return the number of occurances the desired char appears in your array. then you can test for this condition and handle it accordingly:
int get_occurances(char array[], int& size, char& target)
{
int counter = 0;
for(int i=0; i<size; i++)
{
if(array[i] == target)
{
counter++;
}
}
return counter;
}
or you can just use the cout() function from the library:
#include <algorithm>
int counter = 0;
counter = count(&array[0], &array[size], target);
//handle the case of the desired char occuring more than 3 times
if(target > 3)
{
//do whatever you wanted to do here
} Clinton Portis
Practically a Posting Shark
833 posts since Oct 2005
Reputation Points: 237
Solved Threads: 118