-6
如何修復以下程序的c編譯器錯誤?C有不同的數據類型嗎?
struct a{
int a;
};
struct b{
int b;
};
int main(){
int toggle =1;
int y = (toggle==1) && (struct a x);
y = (toggle==0) && (struct b x);
if(toggle==1){
x.a = 10;
printf("%d ",x.a);
}else {
x.b = 20;
printf("%d ",x.b);
}
printf("hi");
return 0;
}
當我編譯這個程序我「之前,‘X’預期‘)’」
得到錯誤,我需要創建靜態對象。還有其他方法可以實現嗎?
什麼是'x'?事實上,int y =(toggle == 1)&&(struct a x); y =(toggle == 0)&&(struct b x); x t;'是什麼意思? – haccks