Skip to content

Latest commit

 

History

History
75 lines (57 loc) · 2.46 KB

set-printf-count-output.md

File metadata and controls

75 lines (57 loc) · 2.46 KB
description title ms.date api_name api_location api_type topic_type f1_keywords helpviewer_keywords ms.assetid
Learn more about: _set_printf_count_output
_set_printf_count_output
11/04/2016
_set_printf_count_output
msvcrt.dll
msvcr80.dll
msvcr90.dll
msvcr100.dll
msvcr100_clr0400.dll
msvcr110.dll
msvcr110_clr0400.dll
msvcr120.dll
msvcr120_clr0400.dll
ucrtbase.dll
api-ms-win-crt-stdio-l1-1-0.dll
DLLExport
apiref
set_printf_count_output
_set_printf_count_output
%n format
set_printf_count_output function
_set_printf_count_output function
d8259ec5-764e-42d0-9169-72172e95163b

_set_printf_count_output

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

Syntax

int _set_printf_count_output(
   int enable
);

Parameters

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

Property value or return value

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

Remarks

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 Format specification syntax: printf and wprintf functions.

Requirements

Routine Required header
_set_printf_count_output <stdio.h>

For more compatibility information, see Compatibility.

Example

// 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

See also

_get_printf_count_output