gpt4 book ai didi

curl下载的文件总是空的

转载 作者:行者123 更新时间:2023-11-30 18:03:39 49 4
gpt4 key购买 nike

在以下示例之后,我尝试使用curl复制文件:

CURL *curl;
FILE *fp;
CURLcode res;
char *url = "http://localhost/aaa.txt";
char outfilename[FILENAME_MAX] = "D:\\bbb.txt";

curl = curl_easy_init();

if(curl)
{
fp = fopen(outfilename,"wb");
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
fclose(fp);
}

它创建了一个名为 bbb.txt 的文件,但该文件为空。你能帮我吗?我的错误是什么?

最佳答案

您错过了对 curl_easy_perform 的调用。请参阅API description其中。

关于curl下载的文件总是空的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8162837/

49 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com