使用VC++6.0打开考生文件夹下的源程序文件2.cpp。请完成函数un(char*str1,char*str2),此函数的功能是计算str1中出现str2的个数,当不出现时,则返回0。
如
str1为“asdfsfdfg”
str2为“sf”则返回1
str2为“df”则返回3
注意:不能修改函数的其他部分。
试题程序:
#include<iostream.h>
//注意只能使用int类型,不能类型转换
int fun(char*str1,char*str2)
void main()
char str1[l024];
char str21256];
cout<<"please input a string:"<<end1;
cin.getline(str1,1024);
cout<<"please input other string:"<<end1;
cin.getline(str2,256);
cout<<fun(str1,str2);
cout<<end1;
return;