_fputc_nolock, _fputwc_nolock

 

For the latest documentation on Visual Studio 2017 RC, see Visual Studio 2017 RC Documentation.

Writes a character to a stream without locking the thread.

int _fputc_nolock(  
   int c,  
   FILE *stream   
);  
wint_t _fputwc_nolock(  
   wchar_t c,  
   FILE *stream   
);  

Parameters

c
Character to be written.

stream
Pointer to the FILE structure.

Each of these functions returns the character written. For error information, see fputc, fputwc.

_fputc_nolock and _fputwc_nolock are identical to fputc and fputwc, respectively, except that they are not protected from interference by other threads. They might be faster because they do not incur the overhead of locking out other threads. Use these functions only in thread-safe contexts such as single-threaded applications or where the calling scope already handles thread isolation.

The two functions behave identically if the stream is opened in ANSI mode. _fputc_nolock does not currently support output into a UNICODE stream.

Generic-Text Routine Mappings

Tchar.h routine_UNICODE and _MBCS not defined_MBCS defined_UNICODE defined
_fputtc_nolock_fputc_nolock_fputc_nolock_fputwc_nolock
FunctionRequired header
_fputc_nolock<stdio.h>
_fputwc_nolock<stdio.h> or <wchar.h>

The console is not supported in Windows 8.x Store apps. The standard stream handles that are associated with the console—stdin, stdout, and stderr—must be redirected before C run-time functions can use them in Windows 8.x Store apps. For more compatibility information, see Compatibility.

// crt_fputc_nolock.c  
// This program uses _fputc_nolock  
// to send a character array to stdout.  
  
#include <stdio.h>  
  
int main( void )  
{  
   char strptr1[] = "This is a test of _fputc_nolock!!\n";  
   char *p;  
  
   // Print line to stream using fputc.   
   p = strptr1;  
   while( (*p != '\0') && _fputc_nolock( *(p++), stdout ) != EOF ) ;  
  
}  

This is a test of _fputc_nolock!!  

Stream I/O
fgetc, fgetwc
putc, putwc

Show: