Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
We recommend using Visual Studio 2017

_set_printf_count_output

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at _set_printf_count_output.

Enable or disable support of the %n format in printf, _printf_l, wprintf, _wprintf_l-family functions.

int _set_printf_count_output(  
   int enable  
);  

Parameters

enable
A non-zero value to enable %n support, 0 to disable %n support.

The state of %n support before calling this function: non-zero if %n support was enabled, 0 if it was disabled.

Because of security reasons, support for the %n format specifier is disabled by default in printf and all its variants. If %n is encountered in a printf format specification, the default behavior is to invoke the invalid parameter handler as described in Parameter Validation. Calling _set_printf_count_output with a non-zero argument will cause printf-family functions to interpret %n as described in printf Type Field Characters.

RoutineRequired header
_set_printf_count_output<stdio.h>

For additional compatibility information, see Compatibility in the Introduction.

// crt_set_printf_count_output.c  
#include <stdio.h>  
  
int main()  
{  
   int e;  
   int i;  
   e = _set_printf_count_output( 1 );  
   printf( "%%n support was %sabled.\n",  
        e ? "en" : "dis" );  
   printf( "%%n support is now %sabled.\n",  
        _get_printf_count_output() ? "en" : "dis" );  
   printf( "12345%n6789\n", &i ); // %n format should set i to 5  
   printf( "i = %d\n", i );  
}  

%n support was disabled.  
%n support is now enabled.  
123456789  
i = 5  

Not applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples.

_get_printf_count_output

Show: