I have a binary file in a remote web server.
And I want to download it with curl in c++.
But in one condition, I cannot write it to a file.
So I have to hold it into char array.
What I have tried so far is,
size_t WriteHtmlCallback(void *ptr, size_t size, size_t count, void *stream)
{
((string*)stream)->append((char*)ptr, 0, size * count);
return size * count;
}
std::string html;
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteHtmlCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &html);
But html string loses binary data.
What's the solution?