title: Using arrays to loop through starting multiple threads, pass different parameters, and return handles for WaitForMultipleObjects
body: <p>I want to test out using WaitForMultipleObjects, and to do so I want to start multiple threads, using a loop, each passing different ThreadArgs. </p>
  
  <p>(Essentially just an array of five ThreadArgs, and five HANDLEs?)</p>
  
  <p>When I try to create an array of either the struct, or the HANDLE, neither will work and I get the error 'cannot allocate an array of constant size 0' for both, and ''initializing' : cannot convert from 'HANDLE' to 'HANDLE []'' for the latter. </p>
  
  <p>Is an array the appropriate way to do this with regards to the struct? (Also, a note - it will have to remain a struct as it will contain six members eventually, I'm just trying to get it working in a simpler form at first, since adding these members should be very straightforward) </p>
  
  <p>And I'd assume an array of Handles is the best way to do this, but how do I go about declaring one? </p>
  
  <p>Thank you! </p>
  
  <pre><code>#include &lt;windows.h&gt;
  #include &lt;iostream&gt; 
  #include &lt;process.h&gt;
  
  
  struct ThreadArgs 
  {
      int id;
  };
  
  ThreadArgs args = {1}; 
  
  
  unsigned int __stdcall MyThread(void *data)
  {
      std::cout &lt;&lt; "Hello World!\n"; 
      ThreadArgs *args = (ThreadArgs *) data; 
  
      std::cout &lt;&lt; (*args).id;
  
      return 2;
  }
  
  int main()
  {
  
      HANDLE hThread = (HANDLE) _beginthreadex(NULL, 0, MyThread, &amp;args, 0, NULL); 
  
      WaitForSingleObject(hThread, INFINITE);
  
  
      while(true);
  
  }
  </code></pre>
  
  <p>The above is my code currently. </p>
  
  <p>I was trying to create an array of HANDLEs using - </p>
  
  <pre><code>HANDLE hThread[5]; 
  </code></pre>
  
  <p><strong>Edit:</strong></p>
  
  <p>The error is on this line, when it is altered to be an array of HANDLE[5] - </p>
  
  <pre><code>HANDLE hThread[0] = (HANDLE) _beginthreadex(NULL, 0, MyThread, &amp;args, 0, NULL); 
  </code></pre>