_fgetc_nolock, _fgetwc_nolock

Lee un carácter de una secuencia sin bloquear el subproceso.

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

Parámetros

  • stream
    Puntero a la estructura de FILE.

Valor devuelto

Veafgetc, fgetwc.

Comentarios

_fgetc_nolock y _fgetwc_nolock son exactamente iguales que fgetc y fgetwc, respectivamente, salvo que no están protegidas contra interferencias de otros subprocesos. Pueden ser más rápidas porque no incurren en la sobrecarga de bloquear otros subprocesos. Use estas funciones solo en contextos seguros para subprocesos como aplicaciones de un único subproceso o donde el ámbito de llamada ya controle el aislamiento de subprocesos.

Asignaciones de rutina de texto genérico

Rutina Tchar.h

_UNICODE y _MBCS no definidos

_MBCS definido

_UNICODE definido

_fgettc_nolock

_fgetc_nolock

_fgetc_nolock

_fgetwc_nolock

Requisitos

Función

Encabezado necesario

_fgetc_nolock

<stdio.h>

_fgetwc_nolock

<stdio.h> o <wchar.h>

Para obtener más información de compatibilidad, vea Compatibilidad en la Introducción.

Ejemplo

// 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 );
}

Entrada: crt_fgetc_nolock.txt

Line one.
Line two.

Resultados

Line one.
Line two.

Equivalente en .NET Framework

Vea también

Referencia

E/S de secuencia

fputc, fputwc

getc, getwc