What is the fastest method to find the number of occurrence of character in a sub-string of string?
I have tried the normal scanning each character but the test data is too large.
What is the fastest method to find the number of occurrence of character in a sub-string of string?
I have tried the normal scanning each character but the test data is too large.
It's very simple
unsigned int countChar(const char *string, char characterOfInterest)
{
unsigned int count;
count = 0;
while ((string = strchr(string, characterOfInterest)) != NULL)
{
count += 1;
string += 1;
}
return count;
}