C++ iostream wcin Object
Example
Use the wcin object to read user input:
int x;
wcout << L"Type a number: ";
wcin >> x;
wcout << L"Your number is: " << x;
Definition and Usage
The wcin object is used to read keyboard input as wide characters (wchar_t). It works like cin, but for wide text.
Use it with the >> extraction operator, which reads the input and stores it in a variable. To read wide text, store it in a wstring (a string of wide characters).
The wcin object is defined in the <iostream> header file.
Note: To avoid problems, do not mix wide and normal streams in one program. Use wcin together with wcout, and cin together with cout.
Syntax
wcin >> variable;
Parameter Values
| Parameter | Description |
|---|---|
| variable | Required. The variable to store the input in. |
Technical Details
| Returns: | The >> operator returns a reference to wcin itself, so you can read into many variables in one statement, like wcin >> x >> y;. |
|---|