Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

cout

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 ?

like image 629
Whizz Mirray Avatar asked Sep 01 '15 18:09

Whizz Mirray


People also ask

What is the difference between Cout and Wcout?

Difference between wcout and coutcout users char (narrow character) as character type. It can be used for ASCII and ANSI characters. For internationalization, we need Unicode strings which do not fit in char. wcout uses wchar_t (wide character) and usable for Unicode characters.

What is std :: Wcout?

std::wcoutObject of class wostream that represents the standard output stream oriented to wide characters (of type wchar_t ). It corresponds to the C stream stdout . The standard output stream is the default destination of characters determined by the environment.

What is the difference between Cout and Cin?

cin is an object of the input stream and is used to take input from input streams like files, console, etc. cout is an object of the output stream that is used to show output. Basically, cin is an input statement while cout is an output statement. They also use different operators.

What is the difference between printf and cout in C++?

Printf is a function which needs parameters and format specifiers (%d for int). Cout is stream oriented output stream object where you do not need any format specifiers. printf returns an integer value (the number of characters actually printed) and cout does not return anything.


1 Answers

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.

like image 56
Dietmar Kühl Avatar answered Oct 14 '22 14:10

Dietmar Kühl