Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I know I can call system("curl path-LJO") from a c++ program to download a file and save it in the current directory and then I can use the STL to save it to a std::string. But is there a way to save it directly in a std::string? I know abot https://github.com/curl/curl but I was wondering: is any specifier in the curl command that does that? If not, what would be the best way to approach this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
207 views
Welcome To Ask or Share your Answers For Others

1 Answer

You need to use the libcurl library in your code. You can use the CURLOPT_READFUNCTION and CURLOPT_READDATA options to setup a callback that saves the received data directly to your std::string variable.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...