_set_printf_count_output
啟用或停用 、 _printf_l
、 wprintf
_wprintf_l
-family 函式中 printf
%n 格式的支援。
語法
int _set_printf_count_output(
int enable
);
參數
enable
啟用 %n 支援的非零值,0 表示停用 %n 支援。
屬性值或傳回值
在呼叫此函式之前,%n 支援的狀態 :如果 已啟用 %n 支援,則為非零,如果停用則為 0。
備註
由於安全性原因, 預設 printf
會停用 %n 格式規範及其所有變體的支援。 如果在 格式規格中 printf
遇到 %n ,預設行為是叫用不正確參數處理常式,如參數驗證 中所述 。 使用非零引數呼叫 _set_printf_count_output
會導致 printf
-family 函式解譯 %n ,如格式規格語法: printf
和 wprintf
函式 中所述 。
需求
常式 | 必要的標頭 |
---|---|
_set_printf_count_output |
<stdio.h> |
如需相容性詳細資訊,請參閱相容性。
範例
// 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
另請參閱
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應