title: Manipulate multidimensional array in a function
body: <p>I read a lot of stuff in here and tried many but i couldn't find a way to pass a multidimensional array to a function in C, change some of the values and somehow return the new array.
  It's important to find a way to pass that array further to another function and do the same thing.</p>
  
  <p>I would like to find a way to pass the array to a function.Then pass it from the first function to a second one,do something there(maybe print,maybe change values),then use it again to the first function and finally use that array in main.</p>
  
  <p>My last try is:</p>
  
  <pre><code>void func(int multarray[][columns]){
      multarray[0][0]=9;
  }
  
  int main(){
      int rows;
      int columns;
      int multarray[rows][columns];
      func(multarray);
      return 0;
  }
  </code></pre>
  
  <p>I also tried this:</p>
  
  <pre><code>void func(int multarray[rows][columns]){
      multarray[0][0]=9;
  }
  
  int main(){
      int rows;
      int columns;
      int multarray[rows][columns];
      func(multarray);
      return 0;
  }
  </code></pre>
  
  <p>I also tried this:</p>
  
  <pre><code>int
  getid(int row, int x, int y) {
            return (row*x+y);
  }
  
  void
  printMatrix(int*arr, int row, int col) {
       for(int x = 0; x &lt; row ; x++) {
               printf("\n");
               for (int y = 0; y &lt;col ; y++) {
                   printf("%d  ",arr[getid(row, x,y)]);
               }
       }
  }
  
  main()
  {
  
      int arr[2][2] = {11,12,21,22};
      int row = 2, col = 2;
  
      printMatrix((int*)arr, row, col);
  
  }
  </code></pre>
  
  <p>from <a href="https://stackoverflow.com/questions/3911400/passing-2d-arrays">here</a></p>
  
  <p>I also tried double pointers.I also read that there is a different approach if the compiler does not support VLAs. I am using gnu.</p>