c++ - Returning a multidimensional dynamic array? -


i've got multi dimensional dynamic array, , can print out 6 rows of 6 columns of zeros, can't return same. function supposed initialize array can passed other functions. doing wrong here? commented out "cout" portions because that's not need do. thanks!

long initializearray (void) {     int = 0, j = 0;     typedef int* rollarray;     rollarray *m = new rollarray[6];     (int = 0; < 6; i++) m[i] = new int[6];     while (j < 6)     {         while (i < 6)         {             m[i][j] = 0;             //cout << m[i][j] << " ";             i++;         }         //cout << endl;         = 0;         j++;     } } 

you should declare function:

int** initializearray(void)

and then:

return m;

at end, if must way. don't forget you'll have manually tell else uses pointer it's 6 x 6 array, , don't forget delete[] arrays when you're done them.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -