Passing a 2d dynamic array to a function in C++

前端 未结 5 1554
长情又很酷
长情又很酷 2021-01-19 23:52

I have this 2d dynamic array and I want to pass it to a function, How would I go about doing that

int ** board;
        board = new int*[boardsize];

                


        
5条回答
  •  轮回少年
    2021-01-20 00:28

    Small code for creation and passing a dynamic double dimensional array to any function. `

     void DDArray(int **a,int x,int y)
     {
       int i,j;
        for(i=0;i<3;i++)
         {
          for(j=0;j<5;j++)
           {
             cout<>arr[i][j];
          }
       }
       DDArray(arr,r,c);
    
    }
    

    `

提交回复
热议问题