多多的问题。。
1.为什么GOTO的标签提示错误。
2.删掉的记录不就没了么,那退票记录又回去了怎么弄。
3.主函数调用函数时为什么提示语法表达错误。
这个程序是火车票订票系统,要实现订票,退票,查询,管理员管理,有得部分还没写,大家给点意见。谢谢啦。
#include"stdio.h"
#define L sizeof(struct tikets)
#define T1 "%s%s%d%d%s"
#define N sizeof(struct you1)
void book();
void inquire();
void you();
struct tikets
{
char name[10];
char name2[10];
int num1;
int num2;
char num3[10];
struct tikets *next;
}*save1;
struct you1
{
char user[10];
char card[20];
struct tikets *u;
}you2;
void main()
{
int *t;
int i;
first:
printf("welcome to the system!\n");
printf("1.intput the data.\n");
printf("2.book the tikets.\n");
printf("3.inquire the tikets.\n");
printf("4.cancel the tikets.\n");
printf("5input your own data.\n");
scanf("%d",&i);
read(struct tikets *save);
switch(i)
{
case '1':
book(struct tikets *save);
break;
case '2':
inquire(struct tikets *save);
break;
/*case '3':
cancel(struct tikets *save);
break;*/
case '4':
you(struct tikets *save);
break;
default:
printf("you enter an error number\n");
}
}
void read(struct tikets *save)
{
FILE *fp;
int j;
fp=open("tikets","r");
for(j=0;j<2;j++)
{
fread(save,L,1,fp);
printf(T1,save);
}
fclose(fp);
}
void book(struct tikets *save)
{
struct tikets *b1,*pre,*b2;
printf("please enter the carnum;\n");
gets(carnum);
b1=save;
while((b1->num3!=carnum)&&(b1->next==NULL))
{
pre=b1;
b1=b1->next;
}
if(b1->num3==carnum)
{
if(b1==save)
save=save->num3;
else
pre->next=b1->next;
free(b1);
you(struct tikets *save);
}
else
printf("the tikets not been found\n");
goto first;
}
void inquire(struct tikets *save)
{
struct tikets *i1;
char place[10];
int c,k;
printf("which place are you leaving?\n");
gets(place);
c=strcmp(place,save->name);
for(k=0;k<2;k++)
{
if(c==0)
printf(T1,save);
else
printf("can not find it.\n");
}
goto first;
}
void you(struct you1 you2)
{
FILE *fp2;
fp2=fopen("you","w");
printf("please ener your infomation:\n");
printf("name cardnum\n");
scanf("%s%s",you2);
fwrite(you2,N,1,fp2);
fclose(fp2);
printf("book successfully!\n");
goto first;
}