共用方式為


_putc_nolock_putwc_nolock

將字元寫入資料流,而不需要鎖定。

語法

int _putc_nolock(
   int c,
   FILE *stream
);
wint_t _putwc_nolock(
   wchar_t c,
   FILE *stream
);

參數

c
待寫入字元。

stream
FILE 結構的指標。

傳回值

請參閱putc、putwc

備註

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

_putwc_nolock_putc_nolock 的寬字元版本;如果資料流是以 ANSI 模式開啟,則這兩個函式的行為相同。 _putc_nolock 目前不支援輸出至 UNICODE 資料流。

根據預設,此函式的全域狀態會限定於應用程式。 若要變更此行為,請參閱 CRT 中的全域狀態

一般文字常式對應

Tchar.h 常式 _UNICODE_MBCS 未定義 _MBCS 已定義 _UNICODE 已定義
_puttc_nolock _putc_nolock _putc_nolock _putwc_nolock

需求

常式 必要的標頭
_putc_nolock <stdio.h>
_putwc_nolock <stdio.h> 或 <wchar.h>

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

程式庫

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

範例

// crt_putc_nolock.c
/* This program uses putc to write buffer
* to a stream. 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;
   /* Make standard out the stream and write to it. */
   stream = stdout;
   for( p = buffer; (ch != EOF) && (*p != '\0'); p++ )
      ch = _putc_nolock( *p, stream );
}

輸出

This is the line of output

另請參閱

資料流 I/O
fputc, fputwc
getc, getwc