What is the difference between std::cout and std::wcout?

社会主义新天地 提交于 2019-12-03 10:03:54

问题


In c++ what is the difference between std::cout and std::wcout?

They both control output to a stream buffer or print stuff to the console, or are they just alike ?


回答1:


They operate on different character types:

  • std::cout uses char as character type
  • std::wcout uses wchar_t as character type

Otherwise both streams write to standard output.




回答2:


Another thing is that both are used with respected input stream.

Objects of these are initialized during or before the first time an object of std::ios_base::Init is created.

  • std::cout is std::basic_ios::tie'd to std::cin and to std::cerr
  • std:wcout is std::basic_ios::tie'd to std::wcin and to std::wcerr


来源:https://stackoverflow.com/questions/32338496/what-is-the-difference-between-stdcout-and-stdwcout

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!