I create an multi dimensional array of dimensions 5 X 5.
I have the first character as, say P. all other's are X.
Now I print the array as a grid and I want it to move one character right if the user enters R, one up if the user enters U and so on.
But I don't know in which cell of the array is the P. So is there any straight forward way to do that? BTW, I was trying to avoid a loop here.
And this is the code that I tried to use:
1 2
|
*PlayerLoc = '.';
*(PlayerLoc+1) = PlayerPeg;
|
this is inside an switch statement. Also,
PlayerLoc = &PlayerPeg
, where PlayerPeg is 'P'.
I have tried this and instead of moving one right, it derectly goes to the very last block of the array (Map[4][4]) and replaces it with a
Any help?