What is wrong with this assignment in a conditional operator?
问题 There is an error. Is it wrong to assign a value to a[i] in the following code? Or something is wrong with conditional operators? #include<stdio.h> #include<string.h> int main(){ char a[12]="sumit tyagi"; int i=0; while(a[i]!='\0'){ a[i]>90 ? a[i]=a[i]-32 : a[i]=a[i]+32; //error in this line i++; } printf("\n %s",a); 回答1: a[i]>90 ? a[i]=a[i]-32 : a[i]=a[i]+32; is not evaluated as a[i]>90 ? (a[i]=a[i]-32) : (a[i]=a[i]+32); since = has lower precedence than ?: . In standard C you can't write it