I tried to copy files with curl after the following example:
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);
}
It creates a file named bbb.txt but the file is empty. May you can help me? What’s my mistake?
You miss a call to
curl_easy_perform. See the API description of it.