title: How to declare a variable sized 2D arrays global in C?
body: <p>I'm making a randomized n*n matrix, but I do not know the value of n until the program is already running.</p>
  
  <p>I'm capable of creating the n*n matrices in main() like so:</p>
  
  <pre><code>    double (*m1)[n];
      m1 = malloc(sizeof *m1 * n);
  
      double (*m2)[n];
      m2 = malloc(sizeof *m2 * n);
  </code></pre>
  
  <p>But now I must use these matrices outside of main and need them to be global, but I'm completely clueless how to make them global. I intend to read these two matrices with multiple threads and need them easily accessible. I know I can make a struct to pass multiple parameters, but I would need to define a struct with variable length arrays globally so the problem rearises. Thank you for your time.</p>