title: Pass an string array to CreateProcess in for loop for multiple processes
body: <p>I have to admit that most of the win32 api stuff I am not familiar with in this code. That being said, I would like to incorporate what I do know into my learning process. I am trying to create a for loop that will <code>CreateProcess</code> multiple times with different arguments each time. In Visual Studio I get a compile error:</p>
  
  <pre><code>source.cpp(138): error C3867: 'std::basic_string&lt;_Elem,_Traits,_Alloc&gt;::c_str': function call        missing argument list; use '&amp;std::basic_string&lt;_Elem,_Traits,_Alloc&gt;::c_str' to create a     pointer to member
  1&gt;          with
  1&gt;          [
  1&gt;              _Elem=char,
  1&gt;              _Traits=std::char_traits&lt;char&gt;,
  1&gt;              _Alloc=std::allocator&lt;char&gt;
  1&gt;          ]
  </code></pre>
  
  <p>When running the following code:</p>
  
  <pre><code>std::string arrString[3] = {"dir","cd ..","dir"};
              int i;
              LPWSTR cmd =L"cmd";
  
              for(i=0; i&lt;3; i++)
              {
              STARTUPINFO info={sizeof(info)};
              PROCESS_INFORMATION processInfo;
              if (CreateProcess(cmd, arrString[i].c_str, NULL, NULL, TRUE, 0, NULL, NULL, &amp;info, &amp;processInfo))
              {
                  ::WaitForSingleObject(processInfo.hProcess, INFINITE);
                  CloseHandle(processInfo.hProcess);
                  CloseHandle(processInfo.hThread);
              }
  </code></pre>
  
  <p>Am I even headed in the right direction?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <pre><code>            std::string arrString[3] = {"cmd","cmd","cmd"};
              int i;
              LPWSTR cmd =L"cmd";
  
              for(i=0; i&lt;3; i++)
              {
                  STARTUPINFO info={sizeof(info)};
                  PROCESS_INFORMATION processInfo;
                  vector&lt;wchar_t&gt; cmdline(arrString[i].begin(), arrString[i].end()); 
                  CreateProcessW(cmd, &amp;cmdline[0], NULL, NULL, TRUE, 0, NULL, NULL, &amp;info, &amp;processInfo);
                      ::WaitForSingleObject(processInfo.hProcess, INFINITE);
                      CloseHandle(processInfo.hProcess);
                      CloseHandle(processInfo.hThread);
  
              }
  </code></pre>