title: Problem starting a process with CreateProcess()
body: <p>The question is given like this:</p>
  
  <blockquote>
    <p>Using the CreateProcess () in the Win32 API. In this instance, you will need to specify a separate program to be invoked from CreateProcess(). It is this separate program that will run as a child process outputting the Fibonacci sequence. Perform necessary error checking to ensure that a non-negative number is passed on the command line.</p>
  </blockquote>
  
  <p>I have done the following. It doesn't show any error message. When I try to execute it, it exits automatically:</p>
  
  <pre><code>#include &lt;sys/types.h&gt;
  #include &lt;windows.h&gt;
  #define _WIN32_WINNT 0x0501
  
  #include &lt;stdio.h&gt;
  
  int main()
  {
  
    STARTUPINFO si;   
    PROCESS_INFORMATION  pi;   
    int a=0, b=1, n=a+b,i,ii;  
  
    ZeroMemory(&amp;si, sizeof(si));
  
    si.cb = sizeof(si);
  
  
    if(! CreateProcess("C:\\WINDOWS\\system32\\cmd.exe",NULL,NULL,NULL,FALSE,0,
                       NULL,NULL,&amp;si,&amp;pi))
      printf("\nSorry! CreateProcess() failed.\n\n");
    else{    
      printf("Enter the number of a Fibonacci Sequence:\n");
      scanf("%d", &amp;ii);
  
      if (ii &lt; 0)
        printf("Please enter a non-negative integer!\n");
      else
      {         
        {
           printf("Child is producing the Fibonacci Sequence...\n");
           printf("%d %d",a,b);
           for (i=0;i&lt;ii;i++)
           {
              n=a+b;
              printf("%d ", n);
              a=b;
              b=n;
           }
           printf("Child ends\n");
        }
  
        {
           printf("Parent is waiting for child to complete...\n");
           printf("Parent ends\n");
        }
      }
    }
  
    WaitForSingleObject(pi.hProcess, 5000);    
    printf("\n");
  
    // Close process and thread handles.    
    CloseHandle(pi.hProcess);
    CloseHandle(pi.hThread);
  
    return 0;
  }
  </code></pre>
  
  <p>What am I doing wrong?</p>