#include<iostream>
#include<string>
using namespace std;
int main()
{
char a[1000],s1;
int count=0;
string s;
getline(cin,s);
strcpy(a,s.c_str());//字符串复制,c_str返回当前字符串首字符地址。
cin>>s1;
for(int i=0;i<s.size();++i)
{
if(toupper(s1)==toupper(a[i]))//转换为大写
count++;
}
cout<<count<<endl;
system("pause");
return 0;
}
=======================================
舟学霸的
#include<iostream>
#include<string.h>
using namespace std;
int main(){
char str[1000];
char sh[1000];
char* result;
int n = 0;
cin.getline(str, 1000);
cin.getline(sh,1000);
for(int i=0;i<1000;i++){
str[i] = tolower(str[i]);
sh[i] = tolower(sh[i]);
}
for (result = strstr(str, sh);result&&++n;)
(result = strstr(result+1,sh));
cout << n << endl;
system("pause");
return 0;
}