在以下示例之后,我尝试使用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
的文件,但该文件为空。你能帮帮我吗?我的错是什么?