对三行文字的字符进行一个统计

我不清楚我的这个特殊字符和空格统计的为啥不对啊 我的特殊字符怎么全加到空格里了 求解

#include<stdio.h>
int main ()
{
    char str[3][80];
    int i,j=0;
    
    int low=0,up=0,space=0,digit=0,other=0;
        for(i=0;i<3;i++)
        {
            printf("第%d行:",i+1); 
            gets(str[i]);
            j=0;
            while(str[i][j]!='\0')
            {
                if(str[i][j]>='A'&&str[i][j]<='Z')
                    up++;
                else if(str[i][j]>='a'&&str[i][j]<='z')
                    low++;
                else if(str[i][j]>='0'&&str[i][j]<='9')
                    digit++;
                else if (str[i][j]=' ')
                    space++; 
                else
                    other++;        
                j++;
            }
        }
            printf("大写字母:%d\n小写字母:%d\n数字:%d\n空格:%d\n其他:%d\n",up,low,digit,space,other);
    return 0;
}

img

空格比较,那边你用了 一个等于号,表明这是一个赋值语句,最终结果是 所有其他特殊字符,包括空格进入这个判断都是 判的 true。

if (" ")  // 空格的ASCII码值是:32,而C语言非0即是真(true)

如有帮助,欢迎采纳哈~

空格那里 = 应该用 ==