【发布时间】:2012-02-22 15:56:23
【问题描述】:
我在控制台中显示 WideString 时遇到问题。一般来说,我对 Builder C++ 和 C++ 完全陌生。不确定我是否需要一些标题或者调试时显示的值可能会有所帮助。好像在做的时候
wcout << s;
它显示的是地址而不是“wchar 数组”。
这是我的代码:
//---------------------------------------------------------------------------
#include <iostream.h>
#include <vcl.h>
#include <string>
#include <wstring.h>
#pragma hdrstop
//---------------------------------------------------------------------------
#pragma argsused
int main(int argc, char* argv[])
{
int a;
WideString s;
string str;
cout << "Enter a: ";
cin >> a;
//to read the return
cin.get();
cout << "Enter str: ";
cin >> str;
//to read the return
cin.get();
cout << "\n";
s = L"HELLO";
wcout << s;
cout << "\n\n";
wcout << L"BYE";
cout << "\n\nPress any key to continue...";
cin.get();
return 0;
}
//---------------------------------------------------------------------------
这就是输出:
Enter a: 4
Enter str: potato
2fb0b4
BYE
Press any key to continue...
【问题讨论】:
标签: console-application c++builder cout