我发现这个资源非常适合开发人员.
我编译了下面的源代码:
gcc demo.c -o demo -I/usr/local/include -L/usr/local/lib -lcurl
Run Code Online (Sandbox Code Playgroud)
基本上,它会下载一个文件并将其保存在您的硬盘上.
文件demo.c
#include <curl/curl.h>
#include <stdio.h>
void get_page(const char* url, const char* file_name)
{
CURL* easyhandle = curl_easy_init();
curl_easy_setopt( easyhandle, CURLOPT_URL, url ) ;
FILE* file = fopen( file_name, "w");
curl_easy_setopt( easyhandle, CURLOPT_WRITEDATA, file) ;
curl_easy_perform( easyhandle );
curl_easy_cleanup( easyhandle );
fclose(file);
}
int main()
{
get_page( "http://blog.stackoverflow.com/wp-content/themes/zimpleza/style.css", "style.css" ) ;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
另外,我相信你的问题类似于这个问题:
归档时间: |
|
查看次数: |
7962 次 |
最近记录: |