C ++ getwchar () - Biblioteca C ++ Padrão

A função getwchar () em C ++ lê o próximo caractere largo de stdin.

A função getwchar () é definida no arquivo de cabeçalho.

protótipo getwchar ()

 wint_t getwchar ();

A função getwchar () é equivalente a uma chamada para getwc (stdin). Ele lê o próximo caractere de stdin, que geralmente é o teclado.

Parâmetros getwchar ()

  • Nenhum.

getwchar () Valor de retorno

  • Em caso de sucesso, a função getwchar () retorna o caractere largo inserido.
  • WEOF é retornado se ocorrer um erro ou se o arquivo for atingido.

Exemplo: Como funciona a função getwchar ()?

 #include #include #include using namespace std; int main() ( int i=0; wchar_t c; wchar_t str(100); setlocale(LC_ALL, "en_US.UTF-8"); wcout << L"Enter characters, Press Enter to stop"; do ( c = getwchar(); str(i) = c; i++; )while(c!=L''); wcout << L"You entered : " << str; return 0; )

Quando você executa o programa, uma possível saída será:

 Insira os caracteres, pressione Enter para parar äs12 ɏ Você digitou: äs12 ɏ

Artigos interessantes...