There are two ways to accomplish what you want to do.
Masks, by the way, can be implemented the same way in QB as in C++. You must use logical operators and bit masks.
Option 1 - In memory or in an array
If you are wanting to preserve the contents of an array or section of memory you do not need to use masks. Before you place your player, ASCII value, or whatever inside the array, save the current value at that location. When you move the player, you can then restore the value which will effectively erase the player and place what was there prior to the player occupying the location.
Option 2 - On the screen
If you wish to do this on screen, simply preserve the ASCII character at screen location row,column and place your player ASCII character at location row,column. When the player leaves location row,column simply place your stored value at that location. The background image or character will be preserved.
Option 3 - Other methods
There are other ways using buffering and other methods, but text mode is so fast, there is almost no need to create a buffer.
Using the array as the 'screen' in memory is one way to buffer the output (look at my first explanation). To draw the screen, simply start at 0,0 and place element 0 of the array there. Iterate through the array and place the value at the appropriate place on the screen. Effectively, your array is what the screen will look like.
Very simplistic explanation of arrays
While I cannot explain all about arrays and their uses here (there are about a million ways to use them), I can explain a simple one dimensional array.
For instance:
This creates an integer array of 11 elements. This is equivalent to the QB statement:
Code:
dim MyArray(0 to 10) as integer
All arrays in C start at 0, while in QBasic they can start at 1 or 0 depending on your OPTION BASE statement. Technically, there is no advantage or disadvantage in regards to whether an array starts at 0 or 1. It's just that in C, all arrays start at 0. However, for most projects you will find that starting at 0 is easier when you start working with offsets into memory, etc.
To access the array simply specify the array element you want.
For instance to access the 0th element of MyArray:
Code:
int test=MyArray[0];
or in QB:
Code:
dim test as integer
test=MyArray(0)
To loop through and print all the elements:
Code:
for (int i=0;i<10;i++)
{
printf("%d ",MyArray[i]);
}
Most of the time in C, you will want to access arrays via pointers, but that definitely cannot be explained in this post as it is a huge topic.
This prints the array in QB:
Code:
for int i=0 to 10 step 1
print MyArray(i);" ";
next
Hope that helps. Since I assumed you knew QB, switching between C and QB may help you understand C a bit better.
There is much, much, much more. Buy a book on C. Books by Bjarne Strousoup (correct spelling?) and Herbert Schildt are excellent and they also cover C++ in great depth. The Sams series of books are great, but I personally do not feel that you can learn and master C in 24 hours or less. C takes a lifetime to master because it is so powerful and versatile.