简体   繁体   English

std :: cout和std :: wcout有什么区别?

[英]What is the difference between std::cout and std::wcout?

In c++ what is the difference between std::cout and std::wcout ? 在c ++中, std::coutstd::wcout什么std::wcout

They both control output to a stream buffer or print stuff to the console, or are they just alike ? 它们都控制输出到流缓冲区或打印到控制台,或者它们是否相似?

They operate on different character types: 它们适用于不同的角色类型:

  • std::cout uses char as character type std::cout使用char作为字符类型
  • std::wcout uses wchar_t as character type std::wcout使用wchar_t作为字符类型

Otherwise both streams write to standard output. 否则两个流都写入标准输出。

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::ios_base::Init的对象期间或之前初始化这些对象。

  • std::cout is std::basic_ios::tie 'd to std::cin and to std::cerr std::coutstd::basic_ios::tiestd::cinstd::cerr
  • std:wcout is std::basic_ios::tie 'd to std::wcin and to std::wcerr std:wcoutstd::basic_ios::tie std::wcinstd::wcinstd::wcerr

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM