Hello to all,
I recently start learning c++ language. I tried various method but I unable to generate a 2D array using void pointer. Can anyone tell me how to use void pointer to generate 2D Array in c++. Please help me.
I have tried following program to generate 2D Array, but it is not working properly.
Code:
int **k;
int rows = 2;
int cols = 2;
k = new int* [rows];
for(int x=0; x< rows; x++)
k[x] = new int[cols];
for (int x = 0; x < rows; x++)
for (int j = 0; y < cols; y++)
k[x][y] = rand () % 10;
Bookmarks