I need help with a piece of code from my project, Theater Seating Program

In the code that I am having a problem with, I am trying to get the user to purchase tickets for seats from a theater but I need the program to check if the seat is taken before selling the ticket. If it is taken, I need it to print out that the seat is taken and allow the user to enter another seat. If it is not taken, I need it to purchase it and change the _(open seat) to X(taken seat). The only problem that I am receiving (as of now, I believe) is that when I go to compile it, I get the error: incompatible types in assignment of 'char' to 'double[2]'. I'm not exactly sure what the error means. This is the section of the program that I am working on below. I'm not looking for someone to do it for me, I would just really like some guidance as to what to do, please and thank you.



void purchaseSeats (double arr[ROWS][COLL][DEFI])
{

int r,//for rows
c;//for columns

int amount;
cout << "How many seats? " ;
cin >> amount;

for (int i = 0; i < amount; i++)
{
cout << "Row: ";
cin >> r;
cout << "C olumn: ";
cin >> c;
arr[r-1][c-1][1]=1;
}
if (arr[ROWS][COLL][DEFI] == 'X ')
{
arr[ROWS][COLL] = '*';
amount++;
}
else
{
cout << "Invalid seat choice";
}

}



Last edited on
First, rewrite arr[ROWS][COLL][DEFI] as arr[r-1][c-1][1] or something like this in body of function. Left arr[ROWS][COLL][DEFI] only in first line in void purchaseSeats (double arr[ROWS][COLL][DEFI]).

Second, you write that arr[ROWS][COLL][DEFI] is a double, but try to compare it with char in if (arr[ROWS][COLL][DEFI] == 'X'). Compare it with numbers or redefine arr. BTW, keep only one char in quotes, remove space after X.

Third, where is third index in arr[ROWS][COLL] = '*';?
You should write something like arr[ROWS][COLL][0] = '*';
Last edited on
Topic archived. No new replies allowed.