does anyone know here how to add cancel seat reservation on my program? i am using c
#include<stdlib.h>
#include <stdio.h>
#include <stdbool.h>
struct block {
char theblock[5][4];
};
struct block blockArray[1];
int main(){
char answer;
bool valid = true;
char blocked_seats[2];
int reserved_seats = 0;
struct block temp = { { {'A', 'B', 'C', 'D'}, {'A', 'B', 'C', 'D'}, {'A', 'B', 'C', 'D'},
{'A', 'B', 'C', 'D'},{'A', 'B', 'C', 'D'}} } ;
blockArray[0] = temp ;
printf("Available seats\n");
for (int i = 0; i < 5; i++){
printf("%d \t",i+1);
for (int j = 0; j < 4; j++){
printf("%c \t",blockArray[0].theblock[i][j]);
}
printf("\n");
}
while(valid == true){
int columnValue;
printf("\nPlease enter seat code to reserve (1B,2A format)\n");
scanf( "%s", blocked_seats );
switch(blocked_seats[1]){
case 'A' : columnValue = 0;
break;
case 'B' : columnValue = 1;
break;
case 'C' : columnValue = 2;
break;
case 'D' : columnValue = 3;
break;
default : break;
}
int columnToBeBlocked = columnValue;
printf("%d",columnToBeBlocked);
char c = blocked_seats[0];
int rowToBeBlocked = c - '0';
printf("%d",rowToBeBlocked);
if(blockArray[0].theblock[rowToBeBlocked-1][columnToBeBlocked] != 'X' && reserved_seats != 20){
blockArray[0].theblock[rowToBeBlocked-1][columnToBeBlocked] = 'X';
reserved_seats++;
printf("seat successfully reserved\n");
for (int i = 0; i < 5; i++){
printf("%d \t",i+1);
for (int j = 0; j < 4; j++){
printf("%c \t",blockArray[0].theblock[i][j]);
}
printf("\n");
}
}
else {printf("seat already taken!\n");
}
if(reserved_seats == 20 )
valid = false;
printf("\nDo you want to assign more seat? Y or N: \n");
scanf(" %c", &answer);
if(answer == 'N')
valid = false;
}
return 0;
}