4
C libcurl获取输出到字符串中
我想将此curl函数的结果存储在变量中,该怎么办? #include <stdio.h> #include <curl/curl.h> int main(void) { CURL *curl; CURLcode res; curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_URL, "curl.haxx.se"); res = curl_easy_perform(curl); /* always cleanup */ curl_easy_cleanup(curl); } return 0; } 谢谢,我这样解决了它: #include <stdio.h> #include <stdlib.h> #include <curl/curl.h> function_pt(void *ptr, size_t size, size_t nmemb, void *stream){ printf("%d", atoi(ptr)); } …