How to define that the space is already occupied?

0

I'm doing a project that makes some reservations and I want to ask the user where he wants to be located (ROW / COLUMN).

How can I do to say that the position is already occupied if someone previously booked it first?

cout<<"\n Escoja su puesto por favor: \n";
cout<<"\n Digite el numero de la fila donde desea ubicarse: ";
cin>>a;
cout<<"\n Digite el numero de la columna donde desea ubicarse: ";
cin>>b; 
cout<<"\n Digite el numero de su documento (cc/ti): ";
cin>>Sur1[a][b].documento;
cout<<"\n Digite su nombre: ";
cin>>Sur1[a][b].nombre;
cout<<"\n Digite su apellido:";
cin>>Sur1[a][b].apellido;
cout<<"\n Digite su numero de telefono: ";
cin>>Sur1[a][b].telefono;
Sur1[a][b].ocupacion=1;
exito();
system("cls");
    
asked by Pedro Antonio Obregon Alomia 01.12.2016 в 15:29
source

1 answer

1

Just check the status of ocupacion . If it is different from 0 it means that the position is occupied.

cout<<"\n Escoja su puesto por favor: \n";

bool ok = false;
do
{
  cout<<"\n Digite el numero de la fila donde desea ubicarse: ";
  cin>>a;
  cout<<"\n Digite el numero de la columna donde desea ubicarse: ";
  cin>>b; 
  if( Sur[a][b].ocupacion != 0 )
    cout << "El sitio ya está ocupado\n";
  else
    ok = true;
} while (!ok);
    
answered by 01.12.2016 в 15:39