O.K. ! Thanks to all who explained me how to use fgets... Now I made some bugfixes in my code... this is the result !!!
So to my problems...Code:void firstclass_select() { //void firstclass_select() begin int v = 0; int w = 0; int x = 0; int y = 0; int z = 0; char select; printf("First Class Selected\n"); plane_graph_first(); while(w == 0) { //while for w 0 begin for(seat = 1; seat <= 16; seat++) { for(a = 1; a <= 1; a++) { if(*first[seat][a] == NULL) empty++; else taken++; } } if(taken == 16) { printf("All seats taken in First Class, press any key to continue..."); getch(); w++; } else printf("\n\nThere are %d empty seats in First Class\n", empty); printf("Enter seat Number: "); scanf("%d", &seat); if((seat <= 0)||(seat > 16)) printf("Out of range ! (1-16)"); else while(y == 0) { //while for y begin if(*first[seat][a] == NULL) { //if array is NULL begin while(x == 0) { //while x for 0 begin printf("Please Enter Gender of Passenger (M) or (F): "); a = 1; gets(first[seat][a]); gets(first[seat][a]); strupr(first[seat][a]); if((first[seat][a] == "M")||(first[seat][a] == "F")); { //if array is M or F begin printf("Please Enter Name of Passenger: "); a++; gets(first[seat][a]); while(v == 0) { //while v for 0 begin printf("Is this a (R)eservation or is this ticket (S)old ?: "); a++; gets(first[seat][a]); strupr(first[seat][a]); if((first[seat][a] == "R")||(first[seat][a] == "S")) { //if array is R or S begin printf("Name of Passenger: %s\n", *first[seat][2]); printf("Gender: %s | Ticket Type: %s\n", *first[seat][1], *first[seat][3]); printf("Passenger Succesful Saved !!"); getch(); v++; x++; y++; z++; } //while array is R or S end else printf("R or S !!!"); } //while v for 0 end } //if array is M or F end else //Why misplaced else ??? printf("M or F !!!"); } //while x for 0 end } //if array is NULL end else { //else begin printf("Seat no. %d is taken", seat); getch(); w++; y++; } //else end }// while for y end } //while for w 0 end getch(); clrscr(); } //void firstclass_select() end
1. Misplaced else ??? in the code... But I still can't figure out why it is a misplaced else (look in the code //misplaced else ??)
2. Actually I tried to check if the user inputs 'M' or 'F' & 'R' & 'S', but it did not work out as good as I thought.
3. When I enter the Gender, Name and R/S thing there, I'll get as output ".l" what does that mean ???
4. Any comments regarding this code are welcome in case of improvement etc... bugifxes...
Thanks in advance
client![]()



LinkBack URL
About LinkBacks



