So, I use the following code to create a two dimensional array of pointers with a specified height and width and then to read values from a file.
int** firstGrid;
firstGrid = new int*[width];
for (int i = 0; i < width; i++)
{
firstGrid[i] = new int [height];
}
//Populated by:
for ( int i = 0; i < width; i++)
{
for (int j = 0; j < height; j++)
{
in >> nextNumber;
firstGrid[i][j] = nextNumber;
}
}
All seems to work great and then I'm trying to print it out.
I've tried:
cout << firstGrid[i][j];
//Which gives the output of the address.
cout << *firstGrid[i][j];
//Which simply won't compile.
cout << *&firstGrid[i][j];
The first option. firstGrid[i][j] will print the integers you allocated in the 2-d array. In this code, though, you haven't initialized them so expect them to be random garbage.