Trouble implementing isalpha

后端 未结 1 1239
迷失自我
迷失自我 2021-01-26 04:12

I\'ve been working on the readability problem in CS50. The first step is to create a way to count only the alphabetical characters. It suggests to use the isalpha f

1条回答
  •  攒了一身酷
    2021-01-26 04:24

    #include 
    #include 
    #include 
    #include 
    
    int main(void)
    {
        const char* s = get_string ("Text: \n");
        int count = 0;
    
        while(*s) count += !!isalpha(*s++);
    
        printf ("%d\n", count );
        return 0;
    }
    

    0 讨论(0)
提交回复
热议问题