Advertisement
Guest User

Untitled

a guest
Sep 19th, 2014
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. Set the absolute path with a variable on Linux using libcurl in C++
  2.  
  3. How can i set the absolute path in libcurl Linux, using a variable?
  4.  
  5. Here's an example code:
  6.  
  7. string absolute_path = "/home/user_name";
  8. CURL *curl;
  9. FILE *fp;
  10. CURLcode res;
  11. const char *url = "http://google.com";
  12. const char outfilename[FILENAME_MAX] = absolute_path;
  13. curl = curl_easy_init();
  14. if (curl)
  15. {
  16. fp = fopen(outfilename,"wb");
  17. curl_easy_setopt(curl, CURLOPT_URL, url);
  18. curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL);
  19. curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
  20. res = curl_easy_perform(curl);
  21. curl_easy_cleanup(curl);
  22. fclose(fp);
  23. }
  24.  
  25. But the compiler returns this error:
  26.  
  27. error: array must be initialized with a brace-enclosed initializer
  28.  
  29. Does anyone know how to fix it? Thank you for your attention!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement