title: Returning a two-dimensional array in C?
body: <p>I recently started programming <code>C</code> just for fun. I'm a very skilled programmer in <code>C# .NET</code> and <code>Java</code> within the desktop realm, but this is turning out to be a bit too much of a challenge for me.</p>
  
  <p>I am trying to do something as "simple" as returning a two-dimensional array from a function. I've tried researching on the web for this, but it was hard for me to find something that worked.</p>
  
  <p>Here's what I have so far. It doesn't quite return the array, it just populates one. But even that won't compile (I am sure the reasons must be obvious to you, if you're a skilled <code>C</code> programmer).</p>
  
  <pre><code>void new_array (int x[n][n]) {
    int i,o;
  
    for (i=0; i&lt;n; i++) {
        for (o=0; o&lt;n; o++) {
          x[i][o]=(rand() % n)-n/2;
        }
    }
  
    return x;
  }
  </code></pre>
  
  <p>And usage:</p>
  
  <pre><code>int x[n][n];
  new_array(x);
  </code></pre>
  
  <p>What am I doing wrong? It should be mentioned that <code>n</code> is a constant that has the value <code>3</code>.</p>
  
  <p><strong>Edit</strong>: Here's a compiler error when trying to define the constant: <a href="http://i.imgur.com/sa4JkXs.png" rel="nofollow">http://i.imgur.com/sa4JkXs.png</a></p>