2D array shifting within the bounds of a larger 2D array

im trying to write a code that allows a 3x3 array shift within the bounds of a 9x9 array. the 3x3 is actually a char* cpaa[3][4] and the 9x9 is a char caArray[9][10]. but I'm having trouble thinking of an algorithm that shifts every index of the 3x3 pointer let alone based on user input. I've been siting on this one for a few weeks and i cant figure anything out. if someone could point me in the right direction i would much appreciate it.
or is it possible to access a single dimension of a 2d array
What do you mean by "array shift"?
like how a window scroll bar works but simpler. I want to cout the 3X3 array in the console window and when the user enters input it slides the scope accordingly to show the hidden information from the larger 9X9 array
Then is sounds like you could make a class that contains an x,y offset of the sub-array. A bit like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class ArrayView
{
    char data[9][9];
    int x, y; // offset
public:
    ArrayView(): data(), x(0), y(0){}

    void set_x(int x) { this->x = x; }
    void set_y(int y) { this->y = y; }

    void print()
    {
        // ... code to output the 3x3 subarray
    }
};
Last edited on
thanks I'll give it a try. much appreciated. I'm not fully familiar with the this pointer but what better time to learn about it. thanks again.
Last edited on
string myString = "OH OK I Think i"
get(this -> const string myString){this-> myString ="it";}
Last edited on
thanx a lot Galik i got it working thanks to your useful tool.
Topic archived. No new replies allowed.