Reputation: 681
In PHP I can do it as simple as :
file_get_contents('http://stackoverflow.com/questions/ask');
What's the shortest code to do the same in C?
UPDATE
When I compile the sample with curl, got errors like this:
unresolved external symbol __imp__curl_easy_cleanup referenced in function _main
Upvotes: 5
Views: 490
Reputation: 5491
I should have commented the Richard Harrison
good answer, but I have not 50 reputations points yet, so I put here as an answer my hint to ieplugin
for compiling the code:
On Ubuntu 10.04 (and supposing you named the source file getpage.c
):
sudo apt-get install libcurl4-dev
gcc getpage.c -lcurl -o getpage
Upvotes: 1
Reputation: 19403
Use libcurl, refer to their example 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;
}
Upvotes: 10