title: How can I download the HTML contents of a webpage using C++
body: <p>Here is my code</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;Windows.h&gt;
  #include &lt;WinInet.h&gt;
  
  using namespace std;
  
  int main()
  {
      HINTERNET hSession, hURL;
      char* Buffer = new char[1024];
      DWORD BufferLen, BytesWritten;
      HANDLE FileHandle;
  
      hSession = InternetOpenA(NULL, 0, NULL, NULL, 0);
      hURL = InternetOpenUrlA(hSession, "http://www.google.co.uk", NULL, 0, 0, 0);
  
      FileHandle = CreateFileA("C:\\temp.txt", GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0);
      BytesWritten = 0;
      do
      {
          InternetReadFile(hURL, Buffer, 1024, &amp;BufferLen);
          WriteFile(FileHandle, Buffer, BufferLen, &amp;BytesWritten, NULL);
      } while (BufferLen != 0);
      CloseHandle(FileHandle);
  
      InternetCloseHandle(hURL);
      InternetCloseHandle(hSession);
  
      ShellExecuteA(0, "open", "C:\\temp.txt", NULL, NULL, 1);
  
      cout &lt;&lt; "Operation complete!";
      system("PAUSE");
      return 0;
  }
  </code></pre>
  
  <p>Here are the errors I am encountering</p>
  
  <pre><code>error LNK2019: unresolved external symbol __imp__InternetOpenA@20 referenced in function _main
  error LNK2019: unresolved external symbol __imp__InternetCloseHandle@4 referenced in function _main
  error LNK2019: unresolved external symbol __imp__InternetOpenUrlA@24 referenced in function _main
  error LNK2019: unresolved external symbol __imp__InternetReadFile@16 referenced in function _main
  </code></pre>
  
  <p>I don't understand where I am going wrong. I have imported Wininet.h and Windows.h. Why is it still having trouble locating these functions? Regards.</p>