_fgetc_nolock, _fgetwc_nolock

Membaca karakter dari aliran tanpa mengunci.

Sintaks

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

Parameter

stream
Penunjuk ke FILE struktur.

Nilai hasil

Lihatfgetc, fgetwc.

Keterangan

_fgetc_nolock dan _fgetwc_nolock identik dengan fgetc dan fgetwc, masing-masing, kecuali bahwa mereka tidak dilindungi dari gangguan oleh utas lain. Mereka mungkin lebih cepat karena mereka tidak menimbulkan overhead penguncian utas lain. Gunakan fungsi-fungsi ini hanya dalam konteks aman utas seperti aplikasi utas tunggal atau di mana cakupan panggilan sudah menangani isolasi utas.

Secara default, status global fungsi ini dicakup ke aplikasi. Untuk mengubah perilaku ini, lihat Status global di CRT.

Pemetaan rutin teks generik

Rutinitas Tchar.h _UNICODE dan _MBCS tidak ditentukan _MBCS Didefinisikan _UNICODE Didefinisikan
_fgettc_nolock _fgetc_nolock _fgetc_nolock _fgetwc_nolock

Persyaratan

Fungsi Header yang diperlukan
_fgetc_nolock <stdio.h>
_fgetwc_nolock <stdio.h> atau <wchar.h>

Untuk informasi kompatibilitas selengkapnya, lihat Kompatibilitas.

Contoh

// 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.

Lihat juga

Streaming I/O
fputc, fputwc
getc, getwc