Share via


_putchar_nolock_putwchar_nolock

將字元寫入至 stdout 而不鎖定。

語法

int _putchar_nolock(
   int c
);
wint_t _putwchar_nolock(
   wchar_t c
);

參數

c
待寫入字元。

傳回值

請參閱putchar、putwchar

備註

putchar_nolock_putwchar_nolock 與沒有 _nolock 後置字元的版本相同,不同之處在於不受保護,不能免於其他執行緒的干擾。 因為其不會造成鎖定其他執行緒的額外負荷,所以可能會比較快。 這些函式只能用在安全執行緒內容 (例如單一執行緒應用程式) 或呼叫範圍已經處理執行緒隔離的地方。

一般文字常式對應

Tchar.h 常式 _UNICODE_MBCS 未定義 _MBCS 已定義 _UNICODE 已定義
_puttchar_nolock _putchar_nolock _putchar_nolock _putwchar_nolock

需求

常式 必要的標頭
_putchar_nolock <stdio.h>
_putwchar_nolock <stdio.h> 或 <wchar.h>

通用 Windows 平台 (UWP) 應用程式中不支援主控台。 與主控台 stdinstdoutstderr 相關聯的標準資料流控制代碼必須重新導向,之後 C 執行階段函式才能在 UWP 應用程式中使用它們。 如需相容性詳細資訊,請參閱相容性

程式庫

所有版本的 C 執行階段程式庫

範例

// crt_putchar_nolock.c
/* This program uses putchar to write buffer
* to stdout. If an error occurs, the program
* stops before writing the entire buffer.
*/

#include <stdio.h>

int main( void )
{
   FILE *stream;
   char *p, buffer[] = "This is the line of output\n";
   int  ch;

   ch = 0;

   for( p = buffer; (ch != EOF) && (*p != '\0'); p++ )
      ch = _putchar_nolock( *p );
}

輸出

This is the line of output

另請參閱

資料流 I/O
fputc, fputwc
fgetc, fgetwc