C Standard Libraries C++

getwchar()

Declaration

wint_t getwchar();

Description

This function reads in a single character from stdin and returns its value as a wide character. If the read was successful, the character that was read is returned as a wide character. Otherwise, the function returns WEOF to indicate an error.

Example

#include <iostream>
#include <cwchar>

int main() {
    using namespace std;

    wcout << "Type a character and hit enter: ";
    wchar_t wChar = getwchar();

    if (wChar != WEOF) {
        wcout << "Char entered = " << wChar << endl;
    } else {
        wcout << "Read Error!" << endl;
    }

    return 0;
}

Output

getwchar() Output
 

© 2007–2024 XoaX.net LLC. All rights reserved.