dynamic memory allocation
this is the question; Write a function that builds a two-dimensional multiplication table with arbitrary sizes for the
two dimensions.
This is what I have done. I have allowed the user to input whatever size table they want by arbitrarily choosing what value they can input. However I cannot get the board to have blank squares. I thought the char would do it. Any suggestions? thanks
Code:
#include <iostream>
using namespace std;
char SQAURE_CHAR = {' '};
const int Board_Size = 14;
int main()
{
int **p_p_multtable;
p_p_multtable = new int* [Board_Size];
for (int i = 0; i < Board_Size; i++)
{
p_p_multtable[i] = new int [Board_Size];
}
for (int i = 0; i < Board_Size; i++)
{
for (int j = 0; j < Board_Size; j++)
{
p_p_multtable[i][j] = SQAURE_CHAR;
}
}
for (int i = 0; i < Board_Size; i++)
{
delete [] p_p_multtable[i];
}
for (int i = 0; i < Board_Size; i++)
{
for (int j = 0; j < Board_Size; j++)
{
cout << p_p_multtable[i][j];
if (j!= Board_Size - 1)
{
cout << " | ";
}
}
cout << endl;
if (i != Board_Size - 1)
{
cout << "----------------------------" << endl;
}
}
return 0;
}