_fgetc_nolock, _fgetwc_nolock

Legge un carattere da un flusso senza bloccare.

Sintassi

int _fgetc_nolock(
   FILE *stream
);
wint_t _fgetwc_nolock(
   FILE *stream
);

Parametri

stream
Puntatore alla struttura FILE.

Valore restituito

Vederefgetc . fgetwc

Osservazioni:

_fgetc_nolock e _fgetwc_nolock sono rispettivamente identici a fgetc e fgetwc, ad eccezione del fatto che non sono protetti da interferenze da 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
_fgettc_nolock _fgetc_nolock _fgetc_nolock _fgetwc_nolock

Requisiti

Funzione Intestazione obbligatoria
_fgetc_nolock <stdio.h>
_fgetwc_nolock <stdio.h> o <wchar.h>

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

Esempio

// crt_fgetc_nolock.c
// This program uses getc to read the first
// 80 input characters (or until the end of input)
// and place them into a string named buffer.

#include <stdio.h>
#include <stdlib.h>

int main( void )
{
   FILE *stream;
   char buffer[81];
   int  i, ch;

   // Open file to read line from:
   if( fopen_s( &stream, "crt_fgetc_nolock.txt", "r" ) != 0 )
      exit( 0 );

   // Read in first 80 characters and place them in "buffer":
   ch = fgetc( stream );
   for( i=0; (i < 80 ) && ( feof( stream ) == 0 ); i++ )
   {
      buffer[i] = (char)ch;
      ch = _fgetc_nolock( stream );
   }

   // Add null to end string
   buffer[i] = '\0';
   printf( "%s\n", buffer );
   fclose( stream );
}

Input: crt_fgetc_nolock.txt

Line one.
Line two.

Output

Line one.
Line two.

Vedi anche

I/O di flusso
fputc, fputwc
getc, getwc