I have received an assignments and although not specified I would like to implement the use of pointer in it. My problem that I am encountering is that I believe I am not passing my 2D array correctly a second time. What I mean by second time is that I would like to pass the array from main to a function and then again from this function to a different function (if anyone knows of some appropriate terminology of doing this I would appreciate if you can share it.) Since I already wrote a bunch of other code, I will provide the method of how I am passing it, if I am doing it correctly I will provide the remaining of the code in order to find if there is another bug within the code.
int main(){
char seats[rows][columns] //rows and columns are global integers
assignSeats(&seats);
}
void assignSeats(char (*sPlan)[rows][columns]){
assignFirstClass(sPlan);
}
void assignFirstClass(char (*sPlan)[rows][columns]){
//user inputs for row and col
(*sPlan)[row][col] = 'X';
}
Just to mention, I am not getting any error, just that I am not getting the value I am giving to the array position. Although the bug could be somewhere else I would first like to confirm that I am doing the passing of the array correctly since this is what is new to me. Thank you in advance for your help.
SOLUTION The problem was not with the method of passing the pointer, simply that instead of:
(*sPlan)[row][col] = 'X';
I wrote:
(*sPlan)[row][col];
It just went pass me multiple times.