Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I've just begun studying
libcurl
and came across strange behavior of
curl_easy_cleanup()
function. The task of the program is primitive: to get html code from site and put it in stdout.
#include <cstdio>
#include <clocale>
#include "curl\curl.h"
int main()
setlocale(LC_ALL, ".utf8"); // deleting this doesn't help
curl_global_init(CURL_GLOBAL_ALL);
CURL* curl = curl_easy_init();
CURLcode res;
if (curl)
curl_easy_setopt(curl, CURLOPT_URL, "https://cbr.ru/currency_base/daily/");
res = curl_easy_perform(curl);
if (res != CURLE_OK)
printf("Error\n");
curl_easy_cleanup(curl); // crash
curl_global_cleanup();
return 0;
All goes well, i have correct output, but curl_easy_cleanup throws access violation exception and program crashes. Why does it do this and how can I fix the problem? Thanks.
UPD: I use Visual Studio 2019 and compile as C++. I came to conclusion, that problem is that site uses https (not http). I tried several http sites and it worked well. How should I treat the https sites then?
–
–
–
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.