C ++ getwchar () - Libreria standard C ++

La funzione getwchar () in C ++ legge il successivo carattere wide dallo stdin.

La funzione getwchar () è definita nel file di intestazione.

prototipo getwchar ()

 wint_t getwchar ();

La funzione getwchar () è equivalente a una chiamata a getwc (stdin). Legge il carattere successivo dallo stdin che di solito è la tastiera.

Parametri getwchar ()

  • Nessuna.

getwchar () Restituisce il valore

  • In caso di successo, la funzione getwchar () restituisce il carattere wide immesso.
  • WEOF viene restituito se si è verificato un errore o viene raggiunta la fine del file.

Esempio: come funziona la funzione 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 esegui il programma, un possibile output sarà:

 Immettere i caratteri, premere Invio per interrompere äs12 ɏ È stato immesso: äs12 ɏ

Articoli interessanti...