title: C++ WinHTTP API reading data
body: <p>I'm trying to download data from a webpage then parse it, the problem is that I cant obtain the value of <code>pszoutbuffer</code> (<code>ZeroMemory</code> function deletes it) i took the code from MSDN example </p>
  
  <pre><code>void  http_connect::read_data(void)
  {
  
     // Keep checking for data until there is nothing left.
     if( bResults )
     {
  
        do
        {
            // Check for available data.
            dwSize = 0;
            if (!WinHttpQueryDataAvailable( hRequest, &amp;dwSize))
                printf( "Error %u in WinHttpQueryDataAvailable.\n",
                GetLastError());
  
           // Allocate space for the buffer.
           pszOutBuffer = new char[dwSize+1];
           if (!pszOutBuffer)
           {
               printf("Out of memory\n");
               dwSize=0;
           }
           else
           {
               // Read the Data.
               ZeroMemory(pszOutBuffer, dwSize+1);
  
               if (!WinHttpReadData( hRequest, (LPVOID)pszOutBuffer, 
                                dwSize, &amp;dwDownloaded))
              {
                    printf( "Error %u in WinHttpReadData.\n", 
                      GetLastError());
              }
  
  
           }
  
        } while( dwSize &gt; 0 );
     }
  }
  </code></pre>