设为首页 加入收藏

TOP

一个Linux下的C语言购票系统(二)
2014-11-24 07:32:38 来源: 作者: 【 】 浏览:3
Tags:一个 Linux 语言 购票 系统
rrive place from time arrive time price number.\n");


scanf("%s%s%f%f%f%d",add1[len],add2[len],&tim1[len],&tim2[len],&pri[len],&num[len]);
printf("\n");
len++;
strcpy(msgbuf.text2,"new");
strcpy(msgbuf.addr1,add1[len]);
strcpy(msgbuf.addr2,add2[len]);
msgbuf.time1=tim1[len];msgbuf.time2=tim2[len];msgbuf.price=pri[len];msgbuf.n=num[len];
if(msgsnd(msgid,(void*)&msgbuf,sizeof(msgbuf),0)==-1)
printf("msgsnd failed.\n");
printf("add successed.\n");
//scanf("%c",&cho);Do you want to add again y/n
//getchar();
//scanf("%c",&cho);
//printf("\n");
//printf("ch=%c\n",cho);
//if(cho=='y')
//{///////////////////888888
//ss=1;
//}/////////////888
//else
//{//////////////9999999999
//ss=0;
//}///////////9999999999999999


///}//////////////777777
}/////////////66666666666/////////////////////////add
if(strncmp(or,"delete",6)==0)//////////////delete
{/////////////////10
char addre1[30];
char addre2[30];
int tt;
int qq=0;
int sss=1;
char choo;
char choos;
printf("delete the message.\n");
//while(sss)
//{/////////////////11
printf("please enter the from place and the arrive place\n");
scanf("%s%s",addre1,addre2);
getchar();
printf("Do you really want to delete the message y/n\n");


scanf("%c",&choo);
printf("choo=%c\n",choo);
printf("\n");
if(choo=='y')


{///////////////////12
strcpy(msgbuf.text2,"delete");
for(i=0;i{//////////////////13
if(strncmp(add1[i],addre1,strlen(addre1))==0&&strncmp(add2[i],addre2,strlen(addre2))==0)
{////////////////////////14
tt=i;


qq++;
}////////////////////////14



}/////////////////////////////13
if(qq==0)
printf("there is no the ticket.\n");
else if(qq>0)
{/////////////////////15


if(tt=len-1)
{///////////////////16
len--;



}/////////////16
else
{/////////////17
for(i=tt;i{////////////18
strcpy(add1[i],add1[i+1]);
strcpy(add2[i],add2[i+1]);
tim1[i]=tim1[i+1];
tim2[i]=tim2[i+1];
pri[i]=pri[i+1];
num[i]=num[i+1];
}////////////////////////18
len--;
}///////////////17


printf("delete successed.\n");


}//////////////////////15



}////////////////////////12


/*printf("Do you want to delete again .y/n\n");
getchar();
scanf("%c",&choos);
printf("\n");
if(choos=='n')
sss=0;*/
if(msgsnd(msgid,(void*)&msgbuf,sizeof(msgbuf),0)==-1)
printf("msgsnd failed.\n");
}/////////////////11//////////delete


//}/////////////10





}/////////////////////333333333
//}
if(ch=='n')
{
printf("msgbuf.text2=%s",msgbuf.text2);
if(strncmp(msgbuf.text2,"mm",2)==0)
{
strcpy(msgbuf.text2,"no");
if(msgsnd(msgid,(void*)&msgbuf,sizeof(msgbuf),0)==-1)
printf("msgsnd failed.\n");
if(msgrcv(msgid,(void*)&msgbuf,sizeof(msgbuf),msg_to_receive,0)==-1)
{
printf("msgrcv failed!\n");
exit(1);
}
printf("msgbuf.text2=%s\n",msgbuf.text2);
printf("msgbuf.text=%s\n",msgbuf.text);
if(strncmp(msgbuf.text,"buy",3)==0)
{
printf("the client buy the ticket.\n");


printf("the %d one,the from place is %s, the arrive place is %s,the number is %d,the total money is %f\n",msgbuf.f,msgbuf.addr1,msgbuf.addr2,msgbuf.n,msgbuf.mon);



}
if(strncmp(msgbuf.text,"return",6)==0)
{
printf("the client return the ticket.\n");
printf("the from place is %s, the arrive place is %s\n",msgbuf.addr1,msgbuf.addr2);


}
if(strncmp(msgbuf.text,"end",3)==0)
{
running=0;
}
}
//}


}
}//////////////////222
if(msgctl(msgid

首页 上一页 1 2 3 下一页 尾页 2/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Linux 下读取指定目录下所有的目.. 下一篇Linux 使用 cp 命令强制覆盖功能

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·Redis 分布式锁全解 (2025-12-25 17:19:51)
·SpringBoot 整合 Red (2025-12-25 17:19:48)
·MongoDB 索引 - 菜鸟 (2025-12-25 17:19:45)
·What Is Linux (2025-12-25 16:57:17)
·Linux小白必备:超全 (2025-12-25 16:57:14)