编写一个函数,用该函数可以统计一个长度为3的字符串在另一个字符串中出现的次数。例如,假定输入字符串“the abcthe they have theren”,子字符串为“the”,则应输出4。 注意:部分源程序在文件PROC2.CPP中。 请勿改动主函数和其他函数中的任何内容,仅在fun()的花括号中填入编写的若干语句。 部分源程序如下: //PROC2.CPP #include <iostream> using namespace std; #define MAX 100 int fun(char *str,char *substr); int main() char str[MAX],substr[3]; int n; cout<<"Please Input the source String\n"; cin>>str; cout<<"Please Input the subString\n"; cin>>substr; n=fun(str, substr); cout<<"The counter is: "<<n<<end1; return 0;
int fun(char *str,char *substr)
//******
【参考答案】
实现此函数功能的方式有多种,下面给出其中一种答案: int fun(char *str,char *subst......