I'm trying to create an array that can be resized, and automatically renumbered, at the moment, what I have works for up to a 3x3 array, but anything larger than that doesn't work. I've tried doing this with int instead of char for the type or the array, but then I'm not able to write a character to the board, only the ascii numerical equivalent.
Any help would be appreciated, thanks.
Board.cpp
void Board::create()
{
ptr = new char *[width];
for (int i=0;i<width;i++)
{
*(ptr + i) = new char[height];
}
int k = 1;
for (int i = 0; i < width; i++)
{
for (int j = 0; j<height;j++)
{
*(*(ptr+i)+j) = k++;
}
}
}
The pointer refers to the protected char **ptr
Board.h
class Board
{
public:
void create();
void display();
void end();
void set_height(int);
void set_width(int);
void write();
protected:
int height, width;
char **ptr;
char Player;
};