Beginner here having a problem with a dynamic 2D array of char that I don't quite understand. I need to fill the array with whitespace and then be able to select certain indices, which would contain whitespace characters, and replace them with something else. Would really appreciate some help.
I've managed to successfully fill the array in the way that I need, by looping through it and assigning ' ' to the current index.
However, when I use my other function, which is included below, something strange happens. The index with a whitespace becomes occupied by a 'W' (I see this by printing the array out) and the function seems to stop working as a result, because it's set to look for ' '.
If I fill the array with another character and set the function up to replace that character with a different character, it works fine.
if (currentSpace == ' ' && movementChoice == 4)
{
pointerToBoard[antCurrentRow][antCurrentColumn] = '&';
}
else if (currentSpace == '&' && movementChoice == 3)
{
pointerToBoard[antCurrentRow][antCurrentColumn] = ' ';
}
I've tried changing ' ' to " " in the function, but I end up with question marks.
I've tried storing ' ' in a char and using it in the function, but I end up with what I described above, a W shows up.
Even had a similar result if I use char(32) instead of ' ' in the function.