I want when I reserve or cancel, the number change, but it doesn't change. Im confused.. please help :!!
print seat code :
int print_seats(void) {
int i, j;
printf(" |0 1 2 3 4\n");
printf(" ---------------\n");
for (i = 0; i < 3; i++)
{
printf("%d|", i);
for (j = 0; j < 5; j++)
{
it doesnt print 0:
printf("%2d ", s[i][j]);
}
printf("\n");
}
printf("\n");
}
reserve code :
int researve(int s[3][5]) {
int row = 0, col = 0;
printf("선택된 메뉴=예약하기\n\n");
printf("예약을 원하는 자리는?(행 열) :");
scanf("%d %d", &row, &col);
succed :
if (s[row][col] == 0)
{
printf("예약이 완료되었습니다\n\n");
s[row][col] = 1;
}
fail : else { printf("예약이 완료되었습니다\n\n"); } return s[3][5]; }
main code :
int main(void) {
int s[3][5] = {{ 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }
};
selecting menu :
printf("선택된 메뉴=좌석 확인하기\n\n");
print_seats();
researve(s[3][5]);
print_seats();
return 0;
}
return s[3][5];at the end of functionint researve(int s[3][5])will access an out of range (non-existent) array element.