#include <curl/curl.h>
#pragma comment( lib, "libcurl.lib" )
size_t write_data(char *buffer,size_t size, size_t nitems,void *outstream)
{
int written = fwrite(buffer, size, nitems, (FILE*)outstream);
return written;
}
int main(int argc, char* argv[])
{
CURL* pCurl = curl_easy_init();
FILE* pFile = fopen( "E:/test.txt", "wb" );
curl_easy_setopt(pCurl, CURLOPT_WRITEDATA, (void*)pFile );
//设置回调函数
curl_easy_setopt(pCurl, CURLOPT_WRITEFUNCTION, write_data);
curl_easy_setopt(pCurl, CURLOPT_URL, "www.google.com.hk");
curl_easy_perform(pCurl);
fclose(pFile);
curl_easy_cleanup( pCurl );
return 0;
}