the cURL example given here
http://curl.haxx.se/libcurl/c/getinmemory.html
shows how to get a url to memory. i would like to开发者_高级运维 change the above code to use in c++ without much change. I would like to replace the malloc and realloc with something else. Is there a way to get the above code to work by using an STL like list or vector of strings to save the url to memory?
as nick has pointed out, luckyspin.org/?p=28 gave me the answer.
static int writer(char *data, size_t size, size_t nmemb,
std::string *buffer)
{
int result = 0;
if (buffer != NULL){
buffer->append(data, size * nmemb);
result = size * nmemb;
}
return result;
}
If you use C++, you can try curlpp : see this question : How do you make a HTTP request with C++?
my2c
精彩评论