This program's supposed to ask for the size of a given seat plan and the seating arrangement (numbers), then it's supposed to ask how many times to swap, then it's supposed to ask which seats are to be swapped then it should display everything in the end. I'm not sure why, but it seems like I'm accessing data that's out of my array.
The dimensions of the array should be constants not variables. Variable size is only allowed when we allocate the array dynamically! How come the code even compiles?
The dimensions of the array should be constants not variables. Variable size is only allowed when we allocate the array dynamically! How come the code even compiles?
Some common compilers allow this, but you're right; the standard does disallow it.
First of all, you should never create an array like you are doing here.
Arrays need to be created using constants, not variables. You should always use dynamic allocation whenever ever you need to create an array, whose size is unknown until run-time.
Secondly, on line 16, you are inputting to index [r][c] instead of [x][y].