统计字符串中的英文字母字符个数 : 编写函数,统计字符串中英文字母的个数。字符串的长度不超过1000。函数的接口定义如下:int AlphaStatistics(char *p);

问题遇到的现象和发生背景 #include <stdio.h>

#include <string.h>

/* 你编写的函数放在这里 */

int main()
{
char str[10001];
gets(str);
printf("Alpha = %d\n",AlphaStatistics(str));
return 0;
}

问题相关代码,请勿粘贴截图 int AlphaStatistics(char *p)

{
int a=0;
scanf("%c",*p);
while(*p!='\0'){
if((*p>='a'&&*p<='z')||(*p>='A'&&*p<='Z')) a++;
}
return(a);
}

运行结果及报错内容 :运行超时
我的解答思路和尝试过的方法
我想要达到的结果:如何解决

#include<stdio.h>
/* 你编写的函数放在这里 */
int AlphaStatistics(char *p)
{
    int a = 0;
    while (*p != '\0') {
        if ((*p >= 'a'&&*p <= 'z') || (*p >= 'A'&&*p <= 'Z')) a++;
        p++;
    }
    return a;
}

int main()
{
    char str[10001];
    gets(str);
    printf("Alpha = %d\n", AlphaStatistics(str));
    return 0;
}