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 ?
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.
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.
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.
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.
They operate on different character types:
std::cout
uses char
as character typestd::wcout
uses wchar_t
as character typeOtherwise both streams write to standard output.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With