unsigned char MaxCharCount(const unsigned char * src)
{
assert(src != NULL);
size_t count[256];
memset(count, 0, sizeof(count));
while (*src != '\0') //统计字符数量
{
count[*src] ++;
src++;
}
size_t index = 0;
size_t max = count[index];
for (size_t i = 0; i < 256; ++i)
{
if (max < count[i]) //寻找出现次数最多的字符
{
max = count[i];
index = i;
}
}
return (unsigned char)index;
}
{
assert(src != NULL);
size_t count[256];
memset(count, 0, sizeof(count));
while (*src != '\0') //统计字符数量
{
count[*src] ++;
src++;
}
size_t index = 0;
size_t max = count[index];
for (size_t i = 0; i < 256; ++i)
{
if (max < count[i]) //寻找出现次数最多的字符
{
max = count[i];
index = i;
}
}
return (unsigned char)index;
}