输入:ABCabc A
输出:2
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main(void){
char str[1000]="\0";
char inputChar='\0';
char* pSrch=str;
int count=0;
scanf("%[a-zA-Z0-9]",str);
scanf(" %c",&inputChar);// %c前面有个空格,用于去除前变面空白
//核心就是这个while
while(*pSrch != '\0'){
if(tolower(*pSrch)==tolower(inputChar)){
count++;
}
pSrch++;
}
printf("%i",count);
return 0;
}