#include <stdio.h>
#include <stdlib.h>
typedef struct
{
int a;
short b;
char * c;
}test_switch1_t;
typedef struct
{
int test1;
int a;
short b;
char * c;
}test_switch2_t;
int main()
{
int flag = 0;
switch (flag)
{
case 0:;
test_switch1_t *test1 = NULL;
break;
case 1:;
// test_switch2_t *test1 = NULL;
break;
default:;
// test_switch1_t *test1 = NULL;
break;
}
return 0;
}
要在case 后面加定义需要加‘;’号;
不同case 之间不能存在同名变量定义;