gpt4 book ai didi

C++ LibCurl - 将 CURLcode 转换为 CString

转载 作者:可可西里 更新时间:2023-11-01 15:59:08 29 4
gpt4 key购买 nike

将“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/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com