wcin 用在什么地方?能否给一个例子。~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

roye2002 2008-12-13 05:09:39
wcin 是 wchar_t类型的输入,怎么用wcin 请给出例子 谢谢!
...全文
13482 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
roye2002 2008-12-14
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 ztz0223 的回复:]
这个问题我就不好说了
因为我手头没有你的那个dev编译器
呵呵

不过这里有一句:

C/C++ code#ifdef _GLIBCXX_USE_WCHAR_T
extern wistream wcin; /// < Linked to standard input
extern wostream wcout; /// < Linked to standard output
extern wostream wcerr; /// < Linked to standard error (unbuffered)
extern wostream wclog; /// < Linked to standard error (buffered)
#endif
//@}…
[/Quote]

呵呵 非常感谢你的回复,我按你的方法试了 可是不行出了很多编译问题。

我用别的编译器试一下。
就呆在云上 2008-12-14
  • 打赏
  • 举报
回复
这个问题我就不好说了
因为我手头没有你的那个dev编译器
呵呵

不过这里有一句:
#ifdef _GLIBCXX_USE_WCHAR_T 
extern wistream wcin; /// < Linked to standard input
extern wostream wcout; /// < Linked to standard output
extern wostream wcerr; /// < Linked to standard error (unbuffered)
extern wostream wclog; /// < Linked to standard error (buffered)
#endif
//@}


你的wcin之类的被宏包含了,估计是你的系统没有定义_GLIBCXX_USE_WCHAR_T

这样,你添加上这个宏定义试试:
#define  _GLIBCXX_USE_WCHAR_T 
#include <iostream>

using namespace std;

int main()
{
wchar_t c;
wcin >> c;
wcout << c << endl;
}

roye2002 2008-12-14
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 ztz0223 的回复:]

dev-cpp,还是低级了点
这样吧,你下载一个新的gcc作为内核试试
不过太复杂
就不说了

建议你用vc2008,没有问题的
[/Quote]
dev-cpp的头文件已经定义了wcin等流对象,怎么就不能用wcin呢? 希望你能继续回答。谢谢!!!!!!!!!!!
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef _GLIBCXX_IOSTREAM
#define _GLIBCXX_IOSTREAM 1

#pragma GCC system_header

#include <bits/c++config.h>
#include <ostream>
#include <istream>

namespace std
{
/**
* @name Standard Stream Objects
*
* The <iostream> header declares the eight <em>standard stream
* objects</em>. For other declarations, see
* http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#10 and the
* @link s27_2_iosfwd I/O forward declarations @endlink
*
* They are required by default to cooperate with the global C library's
* @c FILE streams, and to be available during program startup and
* termination. For more information, see the HOWTO linked to above.
*/
//@{
extern istream cin; ///< Linked to standard input
extern ostream cout; ///< Linked to standard output
extern ostream cerr; ///< Linked to standard error (unbuffered)
extern ostream clog; ///< Linked to standard error (buffered)

#ifdef _GLIBCXX_USE_WCHAR_T
extern wistream wcin; ///< Linked to standard input
extern wostream wcout; ///< Linked to standard output
extern wostream wcerr; ///< Linked to standard error (unbuffered)
extern wostream wclog; ///< Linked to standard error (buffered)
#endif
//@}

// For construction of filebuffers for cout, cin, cerr, clog et. al.
static ios_base::Init __ioinit;
} // namespace std

#endif /* _GLIBCXX_IOSTREAM */
就呆在云上 2008-12-14
  • 打赏
  • 举报
回复

dev-cpp,还是低级了点
这样吧,你下载一个新的gcc作为内核试试
不过太复杂
就不说了

建议你用vc2008,没有问题的
roye2002 2008-12-14
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 ztz0223 的回复:]


C/C++ code#include <iostream>
using namespace std;

int main()
{
wchar_t c;
wcin >> c;
wcout << c << endl;
}




用在输入宽的字符的一类对象比如wchar_t,wstring之类的
[/Quote]

我也是这样做的,但是编译错误,说wcin和wcout没有定义。为什么? 我用的是dev-cpp
就呆在云上 2008-12-14
  • 打赏
  • 举报
回复
恩不谢谢
一起学习
nullah 2008-12-13
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 ztz0223 的回复:]


C/C++ code#include <iostream>
using namespace std;

int main()
{
wchar_t c;
wcin >> c;
wcout << c << endl;
}




用在输入宽的字符的一类对象比如wchar_t,wstring之类的
[/Quote]
up
就呆在云上 2008-12-13
  • 打赏
  • 举报
回复

#include <iostream>
using namespace std;

int main()
{
wchar_t c;
wcin >> c;
wcout << c << endl;
}


用在输入宽的字符的一类对象比如wchar_t,wstring之类的
wuyu637 2008-12-13
  • 打赏
  • 举报
回复
#include <iostream>
#include <locale>

using namespace std;

int main(int argc,char **argv)
{
basic_string<wchar_t> ws;
wcin.imbue(locale("chs"));
wcout.imbue(locale("chs"));
wcin>>ws;
wcout<<ws<<endl;
wcout<<L"按任意键退出!";
cin.get();

return 0;
}

64,652

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧