Any ideas?

/*Cannot get code to function properly*/


#include <stdio.h>
#include <math.h>
#include <string.h>

void initialize_seat(char seat[20][10], char req_seat[20][10]);
int getrow();
int getcol();
int checkseat(char req_seat[20][10], char seat[20][10], int row, int col);
void print_rpt(char seat[20][10]);

int main(void)
{
char req_seat[20][10], seat[20][10], cont = 'Y';
int row, col;
int status;
initialize_seat(seat, req_seat);
while (cont == 'Y' || cont == 'y')
{
row = getrow();
col = getcol();
req_seat[row][col] = 'X';
status = checkseat(req_seat, seat, row, col);
if (status)
{
seat[row][col] = req_seat[row][col];
}
printf("Do You Want To Continue (Y/N)? /n");
scanf("%c", &cont);
}
/* print report */
print_rpt(seat);
return(0);
}

void initialize_seat(char seat[20][10], char req_seat[20][10])
{
int col, row;
for (row = 0; row < 20; ++row)
{
for (col = 0; col < 10; ++col)
{
req_seat[row][col] = 'A';
seat[row][col] = 'A';
}
}
}

int getrow()
{
int row;
printf("Plese Enter Seat's Row: ");
scanf("%d", &row);
return(row);
}

int getcol()
{
int col;
/* Insert Code Here */
printf("Please Enter Seat's Column: ");
scanf("%d", &col);
return(col);
}

int checkseat(char req_seat[20][10], char seat[20][10], int row, int col)
{
int status = 0;
/* Add Code To Check for Seat[col][row] Here! */
/* Check to make sure that seat[col][row] is still blank */
/* If so set seat[col][row] = req_seat[col][row] */
/* If not then print the message "Seat Not Available" */
/* and ask user to reinput req_seat */
while(seat[row][col] == req_seat[row][col])
{
/* Add Code To Re-Input Here! */
printf("Seat Not Available!!\n\nPlease Re-Enter Your Selection!\n\n");
/* Call back to getseat() */
row = getrow();
col = getcol();
req_seat[row][col] = 'X';
}
status = 1;
/* Add code Here to set seat[col][row] = req_seat[col][row] */

return(status);
}

void print_rpt(char seat[20][10])
{
int col, row;
for (row = 0; row < 20; ++row)
{
for (col = 0; col < 10; ++col)
{
printf("%c ", seat[row][col]);
}
printf("\n");
}
}
Use [code] tags.

What is it supposed to do?

What is it actually doing?

What's the problem?
Topic archived. No new replies allowed.