Got some errors.Need help here.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include<string.h>
#include<stdio.h>
void main()
{
int i=0;
char choice;
int count=0;
int row,seat,rw,r,s,x,se;
int waitinglist=0;
char name[80];
char smoke;
char seatn[6][2][80]={'\0'};
char waiting[10][80]={'\0'};
do {
std::cout <<"(A) Reserve a seat\n";
std::cout <<"(B) Cancel a reservation\n";
std::cout <<"(C) Display Seating arrangement\n";
std::cout <<"(D) View Waiting List\n";
std::cout <<"(E) Quit\n";
std::cout <<"ENTER CHOICE : ";
std::cin <<"%s", &choice;
switch(choice)
{
case 'A' :
std::cout <<"\nEnter Passenger Name: ";
std::cin <<"%s",&name;
std::cout <<"Non-smoking Area(Y/N): ";
scanf("%s",&smoke);
if (smoke =='Y')
{
std::cout <<"Enter row you want(1/2/3/4)";
std::cin <<"%d",&r;
std::cout <<"Enter seat you want(Seat(1/2)";
std::cin <<"%d",&s;
if(r<=4 && r>=1 && s>=1 && s<=2)
{
if(seatn[r-1][s-1][80] == '\0')
{
strcpy (seatn[r-1][s-1],name);
std::cout <<"Seat has been saved\n";
count++;
}
else if(seatn[r-1][s-1] != '\0')      // error here
{
std::cout <<"Not available now\n";
}
}
else
{
std::cout <<"Error Input";
}
}
else if (smoke =='N')
{
std::cout <<"Enter row you want(1/2";
std::cin <<"%d",&r;
std::cout <<"Enter seat you want(1/2)";
std::cin <<"%d",&s);
if(r>=1 && r<=2 && s>=1 && s<=2)
{
rw=r+3;
se=s-1;
if(seatn[rw][se][80] == '\0')
{
strcpy (seatn[rw][se],name);
std::cout <<"Seat has been saved\n";
count++;
}
else if(seatn[rw][se][80] != '\0')
{
std::cout <<"Not available now\n";
}
else if(count==0)
{
strcpy (waiting[x],name);
x++;
std::cout <<"Sorry, the flight is full. You will be put in the waiting list\n.";
waitinglist++;
}
}
else
{
std::cout <<"Error Input";
}
}
break;
case 'B' :std::cout <<"haven't done";
break;
case 'C' :std::cout <<"haven't done";
break;
case 'D' :std::cout <<"haven't done";
break;
case 'E' :std::cout <<"Ended";
break;
default  :std::cout <<"Error Input";
}
}while(choice!='E');
}
Last edited on
after I input once why can the program still save my name in used seatn[][]?
how to solve this problem?
closed account (N36fSL3A)
People like it when you use code tags. put [ code] and [/code] around your stuff. (without the space.)
Last edited on by Fredbill30
reply Fredbill30: how to use it? ??
closed account (N36fSL3A)
Edit your post and surround the code with the code tags.
reply Fredbill30:
edited, can you tell me what happened to my program?How to fix it?
closed account (N36fSL3A)
Okay, now all that's left is to indent your code so I can help.
reply Fredbill30: How to do that?
closed account (N36fSL3A)
You don't know how do indent? You tab/space your code so it's easier to understand. Don't tell me you code like this:
1
2
3
4
5
int main()
{
std::cout << "Hello World";
return 0;
}


instead of this:
1
2
3
4
5
int main()
{
    std::cout << "Hello World";
    return 0;
}
Topic archived. No new replies allowed.