C++ 如何将wchar_t数据类型与CURL lib一起使用 #包括 名称空间 { std::size\u t回调( 常量字符*in, 标准:尺寸, 标准::大小\u t数量, 标准::字符串*输出) { const std::size\u t totalBytes(size*num); out->append(in,totalBytes); 返回totalBytes; } } LPTSTR Url(标准::字符串Url){ LPTSTR响应=L'; std::字符串数据; 对于(int i=0;i

C++ 如何将wchar_t数据类型与CURL lib一起使用 #包括 名称空间 { std::size\u t回调( 常量字符*in, 标准:尺寸, 标准::大小\u t数量, 标准::字符串*输出) { const std::size\u t totalBytes(size*num); out->append(in,totalBytes); 返回totalBytes; } } LPTSTR Url(标准::字符串Url){ LPTSTR响应=L'; std::字符串数据; 对于(int i=0;i,c++,C++,我试图将代码转换为仅使用wchar\u t,但当我这样做时,httpData返回空白 将当前代码与char一起使用,httpData正确返回值 curl库是否只支持char 另外,我当前的代码在return wcscpy(response,r.data())行崩溃 在wcscpy.cpp: 我做错了什么?我使用for循环构建代码的方式是一种“糟糕的做法” 我这样做是为了使响应为空白,然后在睡眠时重试。有很多错误 LPTSTR response = L""; // point

我试图将代码转换为仅使用
wchar\u t
,但当我这样做时,
httpData
返回空白

将当前代码与
char
一起使用,
httpData
正确返回值

curl
库是否只支持
char

另外,我当前的代码在
return wcscpy(response,r.data())行崩溃

wcscpy.cpp

我做错了什么?我使用for循环构建代码的方式是一种“糟糕的做法”

我这样做是为了使响应为空白,然后在睡眠时重试。

有很多错误

LPTSTR response = L""; // points to a const string literal. Can't be a target of wcscpy
return wcscpy(response, r.data()); // returns a pointer to a temporary buffer `response`
返回std::string或std::wstring


3次尝试的循环不坏,也不好。

当我像这样返回std::wstring时
std::wstring response=std::wstring(data.begin(),data.end());返回response.data()它得到了很多
☐☐☐☐☐☐离开函数作用域后。
返回response.data()
返回指向已销毁
响应的数据的指针。你读过一些C++书籍吗?声明
std::wstring Url(std::string Url)
LPTSTR和wstring不是一回事吗?