#include
int main(int argc, const char * argv[])
{
char str[10]="ABCABCABD";
char str1[5]="ABCA";
for (int i=0; i
str2[0]=str1[i];
str2[1]=str1[i+1];
int strCount=0;
for (int j=0; j
str3[0]=str[j];
str3[1]=str[j+1];
if (strcmp(str2, str3)==0) {
strCount++;
}
}
printf("子字符串:%s在字符串中含有%d个\n",str2,strCount);
}
return 0;
}
子字符串:AB在字符串中含有3个
子字符串:BC在字符串中含有2个
子字符串:CA在字符串中含有2个