C ++ |用curl显示进度条?

时间:2017-08-10 13:15:55

标签: c++ windows curl libcurl

我想知道如何为curl添加进度条,下面是我的代码,它100%工作我只是想知道如何添加进度条(C ++),如10%> 30%> 100%(WINDOWS操作系统)

CURL *curl;
FILE *fp;
CURLcode res;

char *url= "http://ipv4.download.thinkbroadband.com/5MB.zip";
char outfilename[FILENAME_MAX] = "./ATNA/5MB.zip";


curl_version_info_data * vinfo = curl_version_info(CURLVERSION_NOW);

curl = curl_easy_init();
if (curl) {
    fp = fopen(outfilename,"wb");
    curl_easy_setopt(curl, CURLOPT_URL, url);

    curl_easy_setopt(curl, CURLOPT_CAINFO, "./ca-bundle.crt");
    curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);
    curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, false);

    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);

    curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
    res = curl_easy_perform(curl);
    curl_easy_cleanup(curl);

0 个答案:

没有答案