请问大家break错那了

#include
int main(void)
{
int space=0,enter=0,other=0;
char a;
while(a=getchar()!='#')
{
if (a==' ')
space++;
if (a=='\n')
enter++;
(a!=' '&&a!='\n')?(other++):(break);
}
printf("%d%d%d",space,enter,other);
return 0;
}

(a!=' '&&a!='\n')?(other++):(break);这个语句有问题。

根据我的经验:三目运算符(?:)中只能有计算语句,不能有控制语句。
例如:a ? ++a : continue; a ? ++a : break; a ? ++a : if(){};都会有问题。

没有你这样的用法的,直接改成if的就好了,何必搞那么麻烦,可读性又差

 if(a!=' '&&a!='\n')
            other++;
        else
            break;

PS:while((a=getchar())!='#')这句你少了括号,注意!=优先级是大于=的