Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/56.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
curl下载的文件总是空的_C_Curl - Fatal编程技术网

curl下载的文件总是空的

curl下载的文件总是空的,c,curl,C,Curl,在以下示例之后,我尝试使用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, CURL

在以下示例之后,我尝试使用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\u easy\u perform
的呼叫。看看它的特点