C语言switch语句不能给数组吗?
编译程序时,发现以下语句报语法错误
switch(Decbit)
{
case 0: Decimal[]={0,0,0}; break; //if Decbit=0, None decmimal
case 1: Decimal[]={0x80,0,0}; break; //if Decbit=1, 1 bit decmimal
case 2: Decimal[]={0,0x80,0};break; //if Decbit=2, 2 bits decmimal
case 3: Decimal[]={0,0,0x80};break; //if Decbit=3, bits decmimal
default: Decimal[]={0,0,0}; break; //default, None decmimal
}
把它改为如下:
switch(Decbit)
{
default: break; //default, None decmimal
case 1: Decimal[0]=0x80; break; //if Decbit=1, 1 bit decmimal
case 2: Decimal[1]=0x80; break; //if Decbit=2, 2 bits decmimal
case 3: Decimal[2]=0x80; break; //if Decbit=3, bits decmimal
}
就可以编译可以编译通过
开发环境为MPLAB X IDE V1.5
请高手指教,是不是 C语言switch语句不能给数组赋值?
谢谢