curl WRITEFUNCTION and classes

后端 未结 3 820
名媛妹妹
名媛妹妹 2020-12-06 11:33
class Filter{
private:
    string contents;
    bool Server(void);
public:
    void handle(void *, size_t, size_t, void *);
   };

i have a class he

3条回答
  •  没有蜡笔的小新
    2020-12-06 12:18

    string temp;
    
    curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,handle);
    curl_easy_setopt(curl,CURLOPT_WRITEDATA,&temp);
    
    size_t Filter::handle(void *ptr, size_t size, size_t nmemb, string stream)
    {
        string temp(static_cast(ptr), size * nmemb);
        stream = temp;
        return size*nmemb;
    }
    

    thats how i got it to work.. this will save the website to the string named temp.

提交回复
热议问题