在VS13中我有这段代码:
wstring Result, EmptyString{ L"" };
if( EmptyString == L"" )
Result = wstrprintf( L">%s<", L"" );
Result = wstrprintf( L">%s<", EmptyString );
第一个wsprintf正确返回><
但第二个返回>☐+<
,其中两个中间字符是随机wchars。我认为没有理由。
有替代方案吗?
答案 0 :(得分:1)
%s
需要一个C字符串:EmptyString.c_str()
,而不是std::wstring
个对象。