将“res”变量 (CURLcode) 转换为 CString 的最简单方法是什么?
这是在我的机器上编译良好的标准示例,但我想在 MFC 应用程序中使用它并将结果显示为 MessageBox。感谢您的帮助!
#include <curl/curl.h>
int main(void)
{
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
res = curl_easy_perform(curl);
/* always cleanup */
curl_easy_cleanup(curl);
}
return 0;
}
最佳答案
您可以使用 curl_easy_strerror 函数。
CString str(curl_easy_strerror(res));
或
CString str;
str.Format("curl_easy_perform return %s [%d]",curl_easy_strerror(res),res);
关于C++ LibCurl - 将 CURLcode 转换为 CString,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7164654/