switch怎么出错了
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct Date
{
int year;
int month;
int day;
};
struct Info
{
char num[5]; /* 职工号 */
char name[8]; /* 姓名 */
char sex[6]; /* 性别 */
struct Date q; /* 出生年月*/
char education[8]; /* 学历 */
char duty[8]; /* 职务 */
double wage; /* 工资 */
char addr[12]; /* 地址 */
char phone[8];/* 电话 */
struct Info *next;
};
int w;
void Menu()
{
printf("\n\n\n");
printf(" .................................... \n");
printf(" 录入,请按1\n");
printf(" 浏览,请按2\n");
printf(" 查找,请按3\n");
printf(" 插入,请按4\n");
printf(" 删除,请按5\n");
printf(" 退出,请按0\n");
printf("请选择(0-5):");
scanf("%d",&w);
}
struct Info *Enter()
{
struct Info *l,*s,*p;
int n=1;
l=(struct Info *)malloc(sizeof(struct Info));
p=l;
char a[5];
char b[8];
char c[6];
int y;
int m;
int d;
char e[8];
char f[8];
double g;
char h[12];
char i[8];
printf("...输入职工号,姓名,性别,出生年,月,日,学历,职务,工资,地址,电话...\n结束输入:职工号输入ok,其它信息任意填充.\n");
while(n)
{
memset(a,0,5);
scanf("%s%s%s%d%d%d%s%s%f%s%s",a,b,c,&y,&m,&d,e,f,&g,h,i);
if(strcmp(a,"ok")!=0)
{
s=(struct Info *)malloc(sizeof(struct Info));
strcpy(s->num,a);
strcpy(s->name,b);
strcpy(s->sex,c);
s->q.year=y;
s->q.month=m;
s->q.day=d;
strcpy(s->education,e);
strcpy(s->duty,f);
s->wage=g;
strcpy(s->addr,h);
strcpy(s->phone,i);
s->next=p;
s=p;
}
else
n=0;
}
s->next=NULL;
return l;
}
/*void Export(struct Info *head)
{
struct Info *x;
x=head->next;
printf("...职工号,姓名,性别,出生年,月,日,学历,职务,工资,地址,电话...\n");
while(x!=NULL)
{
printf("%3s%3s%3s%3d%3d%3d%3s%3s%3.2f%3s%3s",x->num,x->name,x->sex,x->q->year,x->q->month,x->q->day,x->education,x->duty,x->wage,x->addr,x->phone);
x=x->next;
printf("\n");
}
}
struct Info *Find1(struct Info *head,double key)
{
struct Info *x;
x=head->next;
while(x!=NULL)
if(x->wage!=key)
x=x->next;
else
break;
return x
}
struct Info *Find2(struct Info *head,char key)
{
struct Info *x;
x=head->next;
while(x!=NULL)
if(x->education!=key)
x=x->next;
else
break;
return x
}*/
void sv()
{
printf("...职工号,姓名,性别,出生年,月,日,学历,职务,工资,地址,电话...\n");
}
int main(void)
{
int n=1;
struct Info *v;
Menu();
while(n)
{
if(w>=0&&w<=5)
{
switch(w)
case 1:{v=Enter();system("CLS");Menu();};break;
case 2:{system("CLS");};break;
}
}
return 0;
}
[解决办法]
加花括号啊。
switch(w){
case 1:{v=Enter();system("CLS");Menu();};break;
case 2:{system("CLS");};break;
}