关于c语言判断字符串类型的问题

img

#include <stdio.h>
#include <ctype.h>

int main()
{
    char str[1000];
    scanf("%s", str);
    const char *p = str;
    int has_digit = 0;
    int has_letter = 0;
    while (*p)
    {
        if (isalpha(*p))
            has_letter = 1;
        else if (isdigit(*p))
            has_digit = 1;
        p++;
    }
    if (has_digit && has_letter)
        printf("mixed\n");
    else if (has_digit)
        printf("digit\n");
    else if (has_letter)
        printf("character\n");
    return 0;
}