【发布时间】:2013-12-22 10:50:37
【问题描述】:
我的问题是,过去在字符串上工作的方法都没有在 wstring 上工作。
所以我问我如何才能轻松清除 wstring 以达到审美目的。
我现在的代码:
while (!foundRightOne)
{
wstring cTitle;
ForegroundWindow = GetForegroundWindow();
cout << "FRGW " << ForegroundWindow << endl;
int len = GetWindowTextLengthW(ForegroundWindow) + 1;
wchar_t * windowTitle = new wchar_t[len];
GetWindowTextW(ForegroundWindow, windowTitle, len);
title += windowTitle;
// OUTPUT
cTitle = L"Title: ";
cTitle += title;
wcout << cTitle << endl;
cTitle = ' ';
//OUTPUT
keyPress = getchar();
system("CLS");
if (keyPress == 'y' || keyPress == 'Y')
{
foundRightOne = true;
}
}
基本上,当我按下y 或Y 时,它会循环播放,当我看到右边的cTitle 时按下它,并且在~20 个循环之后,cTitle 会完全填充上一个循环的文本。
【问题讨论】:
-
std::string和std::wstring除了存储的字符类型外完全相同。无论如何,空格不是清除字符串,字符文字不是宽字符,就像字符串文字不是宽字符串一样。 -
代码没有测试用例。请提供“职称”的定义