共用方式為


_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 串流。

一般文字常式對應

Tchar.h 常式

未定義 _UNICODE and _MBCS

已定義 _MBCS

已定義 _UNICODE

_puttc_nolock

_putc_nolock

_putc_nolock

_putwc_nolock

需求

常式

必要的標頭

_putc_nolock

<stdio.h>

_putwc_nolock

<stdio.h> 或 <wchar.h>

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

程式庫

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

Output

This is the line of output

.NET Framework 對等用法

請參閱

參考

資料流 I/O

fputc、fputwc

getc、getwc