示例源码

#include <iostream>
#include "curl/curl.h"   
using namespace std;

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()
{
	CURL *pCurl;
	FILE* pFile = fopen("1.jpg", "wb");
	pCurl = curl_easy_init();
	curl_easy_setopt(pCurl, CURLOPT_WRITEDATA, (void*)pFile);
	curl_easy_setopt(pCurl, CURLOPT_WRITEFUNCTION, write_data);
	curl_easy_setopt(pCurl, CURLOPT_URL, "http://a2.att.hudong.com/36/48/19300001357258133412489354717.jpg");
	curl_easy_perform(pCurl);
	fclose(pFile);
	curl_easy_cleanup(pCurl);
	cout << "已下载文件到当前工程目录下!\n";
	return 0;
}
上一篇:ORACLE 数据库异常关闭处理办法


下一篇:Oracle数据库物理迁移