一个Linux下的C语言购票系统(2)

{///////////////////12
strcpy(msgbuf.text2,"delete");
for(i=0;i<len;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<len-1;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,IPC_RMID,0)==-1)
{
printf("msgct(IPC_RMID)failed!\n");
exit(1);
}
return 0;
}////////////////1111111

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wwsgxw.html