How can i set the absolute path in libcurl on Linux, using a variable?
Here's an example code:
}
string absolute_path = "/home/user_name";
CURL *curl;
FILE *fp;
CURLcode res;
const char *url = "http://google.com";
const char outfilename[FILENAME_MAX] = absolute_path;
curl = curl_easy_init();
if (curl)
{
fp = fopen(outfilename,"wb");
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
fclose(fp);
}
But the compiler returns this error:
error: array must be initialized with a brace-enclosed initializer
Does anyone know how to fix it? Thank you for your attention!