title: How do you pass a 2d array as an argument?
body: <p>I want to create an adjacency matrix using the code below ,but it keep showing me this error :</p>
  <pre class="lang-none prettyprint-override"><code>||=== Build file: &quot;no target&quot; in &quot;no project&quot; (compiler: unknown) ===|
  D:\abSTD\graph theory\createAdjMat.cpp|6|error: array bound is not an integer constant before ']' token|
  D:\abSTD\graph theory\createAdjMat.cpp|6|error: expected ')' before ',' token|
  D:\abSTD\graph theory\createAdjMat.cpp|6|error: expected unqualified-id before 'int'|
  ||=== Build failed: 3 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
  </code></pre>
  <pre><code>#include &lt;bits/stdc++.h&gt;
  
  using namespace std;
  int N, M;
  
  void createAdjMatrix(int Adj[][N], int arr[][M]) {
    for (int i = 0; i &lt; N; i++) {
      for (int j = 0; j &lt; N; j++) {
        Adj[i][j] = 0;
      }
    }
  
    for (int i = 0; i &lt; M; i++) {
      int x = arr[i][0];
      int y = arr[i][1];
  
      Adj[x][y] = 1;
      Adj[y][x] = 1;
    }
  }
  
  void printAdjMatrix(int Adj[][N]) {
    for (int i = 0; i &lt; N; i++) {
      for (int j = 0; j &lt; N; j++) {
        cout &lt;&lt; Adj[i][j] &lt;&lt; ' ';
      }
      cout &lt;&lt; endl;
    }
  }
  
  int main() {
    // Number of vertices
    N = 5;
  
    // Given Edges
    int arr[][2] = {{1, 2}, {2, 3}, {4, 5}, {1, 5}};
  
    // Number of Edges
    M = sizeof(arr) / sizeof(arr[0]);
  
    // For Adjacency Matrix
    int Adj[N][N];
  
    // Function call to create
    // Adjacency Matrix
    createAdjMatrix(Adj, arr);
  
    // Print Adjacency Matrix
    printAdjMatrix(Adj);
  
    return 0;
  }
  </code></pre>