title: C++ how to pass an uninitialized pointer to a function
body: <pre><code>// I need to download data from the (json-format) file net_f:
  std::ifstream net_f("filename", std::ios::in | std::ios::binary);
  // to a square int array *net of size n:
  int n;
  int * net;
  load_net(net_f, &amp;n, net);
  
  // The size is initially unknown, so I want to do it in the procedure:
  void load_net(std::ifstream&amp; f, int *n, int *net)
  {
      int size; // # of rows (or columns, it's square) in the array
      int net_size; // the array size in bytes
      /*
          some code here to process data from file
      */
      // Returning values:
      *n = size;
      // Only now I am able to allocate memory:
      *net = (int *)malloc(net_size);
      /*
          and do more code to set values
      */
  }
  </code></pre>
  
  <p>Now: the compiler warns me that 'variable "net" is used before its value is set'. Indeed, it is, since I don't have enough information. It also pops-up during the runtime, and I just ignore it.
  How should I rework my code to make it more elegant?
  (BTW it has to be an array, not a vector; I'm copying it then to a CUDA device).</p>