【发布时间】:2018-12-31 06:48:43
【问题描述】:
// included iostream, windows.h
// This issue has been bugging me for ages!!
int main() {
std::wstring pls = L"C:\\yesplease.txt";
static const int SIZE = 100;
WCHAR path[SIZE];
std::wcout << "\"" << path << "\"" << std::endl;
return 0;
}
【问题讨论】:
-
std::wstring::c_str结合std::wcscpy?在询问之前,您至少浏览过文档吗? -
IMO 甚至
std::copy()也应该可以工作 @AlgirdasPreidžius。 @Tato 始终为您正在使用的内容使用显式标头,不要依赖其他标头,包括或正确转发已经声明的内容。 -
@πάνταῥεῖ 在这种情况下我该如何使用副本?我对在第三个参数中放什么感到有点困惑
-
@Tato 把
path放在那里应该可以正常工作。 -
@Tato 请注意,
WCHAR不是标准声明类型,而是由windows.h提供的。在上面的示例中,我使用了wchar_t,它是该窗口特定类型定义的标准等效项。