Welcome

首页 / 软件开发 / C++ / C++查找字符在字符串中出现的次数

C++查找字符在字符串中出现的次数2011-05-31查找字符在字符串中出现的次数:

int count1(char* str,char* s)
{
char* s1;
char* s2;
int count = 0;
while(*str!="")
{
s1 = str;
s2 = s;
while(*s2 == *s1&&(*s2!="")&&(*s1! ="0"))
{
s2++;
s1++;
}
if(*s2 == "")
count++;
str++;
}
return count;
}