_getc_nolock, _getwc_nolock

잠금 없이 스트림에서 문자를 읽습니다.

구문

int _getc_nolock(
   FILE *stream
);
wint_t _getwc_nolock(
   FILE *stream
);

매개 변수

stream
입력 스트림입니다.

반환 값

getc, getwc를 참조하세요.

설명

이러한 함수는 호출 스레드를 잠그지 않는다는 점을 제외하고 getcgetwc와 동일합니다. 이들은 다른 스레드를 잠그는 오버헤드를 유발하지 않으므로 속도가 더 빠를 수 있습니다. 단일 스레드 애플리케이션과 같은 스레드로부터 안전한 컨텍스트 또는 이미 스레드 격리를 처리한 호출 범위에서만 이러한 함수를 사용합니다.

기본적으로 이 함수의 전역 상태는 애플리케이션으로 범위가 지정됩니다. 이 동작을 변경하려면 CRT 전역 상태를 참조하세요.

일반 텍스트 루틴 매핑

Tchar.h 루틴 _UNICODE_MBCS 정의되지 않음 정의된 _MBCS 정의된 _UNICODE
_gettc_nolock getc_nolock getc_nolock getwc_nolock

요구 사항

루틴에서 반환된 값 필수 헤더
getc_nolock <stdio.h>
getwc_nolock <stdio.h> 또는 <wchar.h>

호환성에 대한 자세한 내용은 호환성을 참조하세요.

예시

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

입력: crt_getc_nolock.txt

Line the first.
Line the second.

출력

Input was: Line the first.

참고 항목

스트림 I/O
fgetc, fgetwc
_getch, _getwch
putc, putwc
ungetc, ungetwc