I am working on a project( almost finished) but this last part is ridiculously killing me Here is the code I have:
Code:
Ca_Info rpd[data];
int i=0, choice, transnum,regch,ret=0;
trans ruc;
Ca_Info rting;
FILE *rfp,*verfp;
char stat[]="available";
rfp=File_Handler(rent,App_Read);
verfp=File_Handler(veh,Read_B);
FindByStat(stat,rpd);
printf("\t\t\tAvialable List\n");
while(1)
{
if ((strcmp(rpd[i].status,stat)!=0) &&(i==0))
{
printf("No Cars to rent\n");
system("pause");
return;
}
if(strcmp(rpd[i].status,stat)!=0)
{
break;
}
printf("-----------------------\t-----------------------\t-----------------------\t\n");
printf("-----------------------\t| %d |\t-----------------------\t\n",i+1);
printf("-----------------------\t-----------------------\t-----------------------\t\n");
printf("Reg.No:%d Year:%d 2:No.of Seats:%d 3:Type:%s 4:Model:%s\n5:Colour:%s 6:Status:%s 7:Rent Rate:%.2f 8:Insurance Rate:%.2f\n",rpd[i].regnum,rpd[i].year,rpd[i].no_Seats,rpd[i].type,rpd[i].model,rpd[i].col,rpd[i].status,rpd[i].rent_Rte,rpd[i].irancRte);
printf("-----------------------\t-----------------------\t-----------------------\t\n");
i++;
}
printf("Enter Number choice for car\n");
scanf("%d",&choice);
memcpy(&rting,&rpd[choice-1],sizeof(rpd[choice-1]));
system("cls");
printf("Enter date\n");
scanf("%d %s %d %s %d",&ruc.dte.DD,&ruc.dte.sls,&ruc.dte.MM,&ruc.dte.sls1,&ruc.dte.YY);
printf("Enter customer full name(Use - for spaces)\n");
scanf("%s",ruc.c_Nme);
printf("Enter driver's License #\n");
scanf("%d",&ruc.d_Lic);
printf("Enter address(Use - for spaces)\n");
scanf("%s",ruc.addr);
printf("Enter name of a sponsor(Use - for spaces)\n");
scanf("%s",ruc.spon_Nme);
printf("Enter duration of rental in days\n");
scanf("%d",&ruc.time);
printf("Enter credit card number\n");
scanf("%s",ruc.cre_Crd);
printf("Enter name on credit card(Use - for spaces)\n");
scanf("%s",ruc.crd_Own);
ruc.ins_Cost= rting.irancRte * ruc.time;
ruc.rnt_Cost= (rting.rent_Rte * ruc.time)+ruc.ins_Cost;
while(1)
{
Random(ruc.transnum,6);
ret = FindInfo(rfp,NULL,atoi(ruc.transnum),0);
if (!ret)
{
continue;
}
else
{
break;
}
}
strcpy(rting.status,"Out");
fflush(rfp);
fprintf(rfp,"%s\t%d\t%d\t%s\t%d%s%d%s%d\t%d\t%.2f\t%.2f\t%s\t%s\n",ruc.transnum,rting.regnum,ruc.d_Lic,ruc.c_Nme,ruc.dte.DD,ruc.dte.sls,ruc.dte.MM,ruc.dte.sls1,ruc.dte.YY,ruc.time,ruc.ins_Cost,ruc.rnt_Cost,ruc.cre_Crd,rting.status);
regch=rting.regnum;
Update(regch);
fclose(rfp);
fclose(verfp);
}
Comment