如何在C ++ / CX中将String ^转换为std :: string [英] How to convert String^ to std::string in C++/CX
问题描述
大家好,我对C ++ / CX没有多少经验。我有需要将C#字符串数据转换为C ++ std :: string数据。
我试过以下代码,它给出了构建错误:未解析的外部符号。
C ++代码:
String ^ req;
std :: wstring ws(req-> Data());
std :: string request((const char *)& ws [0],sizeof(wchar_t)/ sizeof(char)* ws.size());
_networkApi->发布(请求);
PostRequest方法的定义如下:
void Post(std :: string& s);
当我删除_networkApi-> Post(请求)时。然后项目成功构建。请建议我一个解决方案。
提前致谢... :)
Pallam Madhukar Windows Phone开发人员
< blockquote>
我想这篇文章的String转换部分:
http ://msdn.microsoft.com/en-us/library/windows/apps/hh699879.aspx 包含您需要的所有信息。
Hi all, I don't have much experience with C++/CX. I have requirement where I need to convert the C# string data to C++ std::string data.
I have tried following code which is giving build error: unresolved external symbol.
C++ Code:
String^ req; std::wstring ws(req->Data()); std::string request((const char*)&ws[0], sizeof(wchar_t) / sizeof(char)*ws.size()); _networkApi->Post(request);
The definition of the PostRequest method as below:
void Post (std::string &s);
When I removed _networkApi->Post(request). then the project build successfully. Please suggest me a solution.
Thanks in advance... :)
Pallam Madhukar Windows Phone Developer
I guess the section String conversions of this article: http://msdn.microsoft.com/en-us/library/windows/apps/hh699879.aspx contains all the information you need.
这篇关于如何在C ++ / CX中将String ^转换为std :: string的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!