Share via


_getch_nolock, _getwch_nolock

Ottiene un carattere dalla console senza eco e senza blocco.

Importante

Non è possibile usare questa API nelle applicazioni eseguite in Windows Runtime. Per altre informazioni, vedere Funzioni CRT non supportate nelle app della piattaforma UWP (Universal Windows Platform).

Sintassi

int _getch_nolock( void );
wint_t _getwch_nolock( void );

Valore restituito

Restituisce il carattere letto. Non viene restituito alcun errore.

Osservazioni:

_getch_nolock e _getwch_nolock sono identiche a _getch e a _getchw, ad eccezione del fatto che non sono protette da interferenze da parte di altri thread. Potrebbero essere più veloci perché non comportano il sovraccarico di blocco di altri thread. Utilizzare queste funzioni solo in contesti thread-safe come applicazioni a thread singolo o dove l'ambito chiamante già gestisce l'isolamento del thread.

Per impostazione predefinita, lo stato globale di questa funzione è limitato all'applicazione. Per modificare questo comportamento, vedere Stato globale in CRT.

Mapping di routine di testo generico

Routine Tchar.h _UNICODE e _MBCS non definito _MBCS Definito _UNICODE Definito
_gettch_nolock _getch_nolock _getch_nolock _getwch_nolock

Requisiti

Ciclo Intestazione obbligatoria
_getch_nolock <conio.h>
_getwch_nolock <conio.h> o <wchar.h>

Per altre informazioni sulla compatibilità, vedere Compatibility (Compatibilità).

Esempio

// crt_getch_nolock.c
// compile with: /c
// This program reads characters from
// the keyboard until it receives a 'Y' or 'y'.

#include <conio.h>
#include <ctype.h>

int main( void )
{
   int ch;

   _cputs( "Type 'Y' when finished typing keys: " );
   do
   {
      ch = _getch_nolock();
      ch = toupper( ch );
   } while( ch != 'Y' );

   _putch_nolock( ch );
   _putch_nolock( '\r' );    // Carriage return
   _putch_nolock( '\n' );    // Line feed
}
abcdefy
Type 'Y' when finished typing keys: Y

Vedi anche

I/O della console e della porta
_getche, _getwche
_cgets, _cgetws
getc, getwc
_ungetch, _ungetwch, _ungetch_nolock_ungetwch_nolock