_getc_nolock, _getwc_nolock
legge un carattere da un flusso.
int _getc_nolock(
FILE *stream
);
wint_t _getwc_nolock(
FILE *stream
);
Parametri
- stream
flusso di input.
Valore restituito
Vedere getc, getwc.
Note
queste funzioni sono identiche a getc e getwc con la differenza che non blocca il thread chiamante.Potrebbe essere più veloce perché non comportano un sovraccarico di bloccare escludere altri thread.Utilizzare queste funzioni solo in contesti thread-safe come applicazioni a thread singolo o della pipe chiamante di ambito già threading di isolamento.
Mapping di routine a testo generico
routine di Tchar.h |
_UNICODE e _MBCS non definiti |
_MBCS definito |
_UNICODE definito |
---|---|---|---|
_gettc_nolock |
getc_nolock |
getc_nolock |
getwc_nolock |
Requisiti
routine |
Intestazione di associazione |
---|---|
getc_nolock |
<stdio.h> |
getwc_nolock |
<stdio.h> o <wchar.h> |
Per ulteriori informazioni sulla compatibilità, vedere compatibilità nell'introduzione.
Esempio
// crt_getc_nolock.c
// Use getc to read a line from a file.
#include <stdio.h>
int main()
{
char buffer[81];
int i, ch;
FILE* fp;
// Read a single line from the file "crt_getc_nolock.txt".
fopen_s(&fp, "crt_getc_nolock.txt", "r");
if (!fp)
{
printf("Failed to open file crt_getc_nolock.txt.\n");
exit(1);
}
for (i = 0; (i < 80) && ((ch = getc(fp)) != EOF)
&& (ch != '\n'); i++)
{
buffer[i] = (char) ch;
}
// Terminate string with a null character
buffer[i] = '\0';
printf( "Input was: %s\n", buffer);
fclose(fp);
}
input: crt_getc_nolock.txt
Line the first.
Line the second.
Output
Input was: Line the first.