hi guys, trying to figure out how to put X when seat is taken plz help


[//Airplane Seat Assigning system.

#include<iostream>
using namespace std;

int main()
{
 char seat [7][4]={}; //initalize 7 rows and 4 columns
 char arr[4]={'a','b','c','d'};
 int i,j;
 int row, colnum;
 char col;

 for(i=1;i<=7;i++)
 
 {

  for(j=1;j<=4;j++)
  {
  //cout<<seat[i+1][j+1];
  seat[i-1][j-1]=arr[j-1];
  cout<<arr[j-1];
  }
  cout<<endl;
 }
int x;
 while(true){
 cout<<"Row number :"<<endl;
 cin>>row;
 cout<<"Column: "<<endl;
 cin>>col;
 cout<< seat[row-1][col-1]<<"\n";
  if(seat[row-1][col-1]=='X')
  {
  cout<<"\tSeat has been taken"<<endl;

  continue;
  system("CLS");
//switch()
   //case 1:

 }
   seat[row-1][col-1]='X';
 
 
  for(i=1;i<=7;i++)
 {
  for(j=1;j<=4;j++)
  {
   cout<<seat[i-1][j-1];


  }
  cout<<endl;
  }
 
 }
 system("CLS");
 system("pause");
 return 0;
}

]

you are inputting the column into a char, and then using it to address the seat! thats wrong.. so u should compare the column input with 'a', 'b', 'c', and 'd'..
if its 'a' then column = 0;
if its 'b' then column = 1; // and so on..

#include<iostream>
using namespace std;

int main()
{
	char seat [7][4]={}; //initalize 7 rows and 4 columns
	char arr[4]={'a','b','c','d'};
	int i,j;
	int row, colnum;
	char col;

	for(i=1;i<=7;i++)
	{
		for(j=1;j<=4;j++)
		{
			//cout<<seat[i+1][j+1];
			seat[i-1][j-1]=arr[j-1];
			cout<<arr[j-1];
		}
		cout<<endl;
	}
	int x;
	while(true){
		cout<<"Row number :"<<endl;
		cin>>row;
		cout<<"Column: "<<endl;
		cin>>col;
		if (col == 'a')
			colnum = 0;
		else if (col == 'b')
			colnum = 1;
		else if (col == 'c')
			colnum = 2;
		else if (col == 'd')
			colnum = 3;
		cout<< seat[row-1][colnum]<<"\n";
		if(seat[row-1][colnum]=='X')
		{
			cout<<"\tSeat has been taken"<<endl;
			continue;
			system("CLS");
			//switch()
			//case 1:
		}
		seat[row-1][colnum]='X';
		for(i=1;i<=7;i++)
		{
			for(j=1;j<=4;j++)
			{
				cout<<seat[i-1][j-1];
			}
			cout<<endl;
		}
	}
	system("CLS");
	system("pause");
	return 0;
}
]
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.