What is the most efficient way to get the source code of a webpage in C?

In PHP, I can do this as simple as:

file_get_contents('http://stackoverflow.com/questions/ask');

What is the shortest code that will do the same in C ?

UPDATE

When I compile a sample with curl, I get errors like this:

unresolved external symbol __imp__curl_easy_cleanup referenced in function _main 
+5
source share
3 answers

Use libcurl , refer to their sample C snippets

#include <stdio.h>
#include <curl/curl.h>

int main(void)
{
  CURL *curl;
  CURLcode res;

  curl = curl_easy_init();
  if(curl) {
    curl_easy_setopt(curl, CURLOPT_URL, "curl.haxx.se");
    res = curl_easy_perform(curl);

    /* always cleanup */ 
    curl_easy_cleanup(curl);
  }
  return 0;
}
+10
source

Richard Harrison, 50 , ieplugin :

Ubuntu 10.04 ( , getpage.c):

sudo apt-get install libcurl4-dev
gcc getpage.c -lcurl -o getpage
+1
source

All Articles