Passing 2dimemnsional array to the function in c++ -


this question has answer here:

how pass 2d array function have created 1 , wanted define function initialize array.

#include <iostream>  using namespace std; int n = 5;**strong text** void wypelnijtablicebooli(bool** b){       for(int = 0; < n; i++){         for(int j = 0; j < n; j++)             b[i][j] = 0;     } } int main(){     bool b[n][n];     wypelnijtablicebooli(b);     return 0; } 

and get

error: cannot convert 'bool (*)[(((unsigned int)(((int)n) + -0x000000001)) + 1)][(((unsigned int)(((int)n) + -0x000000001)) + 1)]' 'bool**' argument '1' 'void wypelnijtablicebooli(bool**)'| 

arrays aren't pointers. "first" (dominant) dimension of array can decay pointer when passed function. otherwise, if have multidimensional array, have declare in function argument list accordingly:

void functaking2darray(int (*arr)[5]) {     // stuff }  int array[10][5]; functaking2darray(array); 

Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -