#include<stdio.h>
void main(void)
{
char arr[1024] = "";
char *p = NULL;
int uppercase = 0, lowercase = 0, digit = 0, punctuator = 0;
p = arr;
printf("请输入任意字符串:\n");
scanf("%s", arr);
for (int i = 0; i < strlen(arr); i++)
{
if (*(p + i) >= '0'&&*(p + i) <= '9')
{
digit++;
}
else if (*(p + i) >= 'a'&&*(p + i) <= 'z')
{
lowercase++;
}
else if (*(p + i) >= 'A'&&*(p + i) <= 'Z')
{
uppercase++;
}
else
{
punctuator++;
}
}
printf("大写的字母有%d个\n", uppercase);
printf("小写的字母有%d个\n", lowercase);
printf("数字有%d个\n", digit);
printf("标点符号有%d个\n", punctuator);
}
运行截图: