Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Set the absolute path with a variable on Linux using libcurl in C++
- How can i set the absolute path in libcurl 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!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement