C++ iostream wcout Object
Example
Use the wcout object to output a wide string and a wide character:
wstring greeting = L"Hello World!";
wchar_t letter = L'A';
wcout << greeting << L"\n";
wcout << letter;
Definition and Usage
The wcout object is used to output wide characters (wchar_t) to the console. It works like cout, but for wide text.
A wide character (wchar_t) is a character type that can store more different characters than char. Wide text is written with an L in front, like L"Hello". A string of wide characters is a wstring.
The wcout object is defined in the <iostream> header file.
Note: Do not use both cout and wcout in the same program. They write to the same output, and mixing them can give wrong or missing output.
Syntax
wcout << value;
Parameter Values
| Parameter | Description |
|---|---|
| value | Required. The value to output, like wide text (L"text"), a number, or a wchar_t character. |
Technical Details
| Returns: | The << operator returns a reference to wcout itself, so you can use << many times in one statement. |
|---|