亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

directory search
Algorithms Algorithms(算法) bsearch bsearch_s qsort qsort_s Atomic operations Atomic operations library(原子操作庫) ATOMIC_*_LOCK_FREE atomic_compare_exchange_strong atomic_compare_exchange_strong_explicit atomic_compare_exchange_weak atomic_compare_exchange_weak_explicit atomic_exchange atomic_exchange_explicit atomic_fetch_add atomic_fetch_add_explicit atomic_fetch_and atomic_fetch_and_explicit atomic_fetch_or atomic_fetch_or_explicit atomic_fetch_sub atomic_fetch_sub_explicit atomic_fetch_xor atomic_fetch_xor_explicit atomic_flag atomic_flag_clear atomic_flag_clear_explicit ATOMIC_FLAG_INIT atomic_flag_test_and_set atomic_flag_test_and_set_explicit atomic_init atomic_is_lock_free atomic_load atomic_load_explicit atomic_signal_fence atomic_store atomic_store_explicit atomic_thread_fence(線程圍欄) ATOMIC_VAR_INIT kill_dependency memory_order(內(nèi)存排序) C keywords auto(自動存儲) break(跳出循環(huán)) C keywords(關(guān)鍵詞) case char const(常量修飾符) continue default(預設(shè)運算式) do double(雙精度浮點型) else enum(枚舉類型) extern(全局變量) float(浮點數(shù)) for fortran goto(goto語句) if(if語句) inline(行內(nèi)函式) int long(長整型) register(寄存器變量) restrict( restrict類型限定符) return short signed sizeof(sizeof運算符) static(靜態(tài)變量) struct(結(jié)構(gòu)體) switch(switch語句) typedef(typedef關(guān)鍵字) union(聯(lián)合體) unsigned(無符號) void(空類型) volatile(volatile變量) while(while語句) _Alignas _Alignof _Atomic _Bool _Complex _Generic _Imaginary _Noreturn _Static_assert _Thread_local C language #define directive #elif directive #else directive #endif directive #error directive #if directive #ifdef directive #ifndef directive #include directive #line directive #pragma directive alignas(對齊指定符) Alternative operators and tokens(替代運算符和令牌) Analyzability Arithmetic operators Arithmetic types Array declaration(數(shù)組聲明) Array initialization(陣列初始化) ASCII Chart Assignment operators(賦值運算符) types(atomic類型限定符) Basic concepts Bit fields(位域) break statement C language C Operator Precedence cast operator character constant(字符字面量) Comments(注釋符) Comparison operators(比較運算符) compound literals(符合字面量) Conditional inclusion(條件包含) Conformance(一致性) const type qualifier(const 限定符) Constant expressions(常量表達) continue statement Declarations(聲明) do-while loop Enumerations(枚舉類型) Escape sequences(轉(zhuǎn)義字符) Expressions(表達式) External and tentative definitions(外部和暫定的定義) File scope(文件范圍) floating constant(浮點常量) for loop Function declarations(函數(shù)聲明) Function definitions(函數(shù)聲明) Functions Generic selection泛型選擇 goto statement Identifier(標示符) if statement Implicit conversions(隱式轉(zhuǎn)換) Increment/decrement operators(前置/后置操作符) Initialization(初始化) inline function specifier(內(nèi)聯(lián)函式) integer constant Lifetime(生命期) Logical operators(邏輯運算符) Lookup and name spaces Main function(主函式) Member access operators(會員接入運營商) Memory model Objects and alignment(字節(jié)對齊) Order of evaluation(評估順序) Other operators Phases of translation(翻譯階段) Pointer declaration Preprocessor(預處理) restrict type qualifier(restrict類型限定符) return statement Scalar initialization(標量類型初始化) Scope(范圍) sizeof operator(sizeof運算符) Statements(陳述) static assert declaration(靜態(tài)斷言聲明) Static storage duration(靜態(tài)存儲周期) Storage-class specifiers(存儲類說明符) string literals(字符串字面量) Struct and union initialization(結(jié)構(gòu)體與聯(lián)合體初始化) Struct declaration(結(jié)構(gòu)體聲明) switch statement Thread storage duration(線程存儲時間) Type Type(類型) Typedef declaration(Typedef聲明) Undefined behavior(未定義行為) Union declaration(聯(lián)合體聲明) Value categories(值類別) Variadic arguments(變長參數(shù)宏) volatile type qualifier(volatile 類型限定符) while loop _Alignof operator _Noreturn function specifier Date and time asctime(asctime函數(shù)) asctime_s clock CLOCKS_PER_SEC clock_t ctime(ctime函數(shù)) ctime_s Date and time utilities(日期和時間庫) difftime(計算兩個時間的間隔) gmtime gmtime_s localtime localtime_s mktime(將時間結(jié)構(gòu)數(shù)據(jù)轉(zhuǎn)換成經(jīng)過的秒數(shù)的函數(shù)) strftime(格式化輸出時間函數(shù)) time timespec timespec_get time_t tm wcsftime(格式化時間寬字符) Dynamic memory management aligned_alloc C memory management library(內(nèi)存管理庫) calloc free(釋放動態(tài)分配空間的函數(shù)) malloc(動態(tài)分配內(nèi)存空間的函數(shù)) realloc(重新分配內(nèi)存空間的函數(shù)) Error handling abort_handler_s assert(斷言) constraint_handler_t errno(錯誤報告) Error handling(錯誤處理) Error numbers(錯誤個數(shù)) ignore_handler_s set_constraint_handler_s static_assert File input/output clearerr(清除/復位) fclose feof ferror fflush(清空文件緩沖區(qū)) fgetc fgetpos fgets fgetwc fgetws File input/output fopen fopen_s fprintf fprintf_s fputc fputs fputwc fputws fread freopen freopen_s fscanf fscanf_s fseek fsetpos ftell fwide fwprintf fwprintf_s fwrite fwscanf fwscanf_s getc getchar gets gets_s getwchar perror printf printf_s putc putchar puts putwc putwchar remove rename rewind scanf scanf_s setbuf setvbuf snprintf sprintf sscanf sscanf_s swprintf swprintf_s swscanf swscanf_s tmpfile tmpfile_s tmpnam tmpnam_s ungetc ungetwc vfprintf vfprintf_s vfscanf vfscanf_s vfwprintf vfwprintf_s vfwscanf vfwscanf_s vprintf vprintf_s vscanf vscanf_s vsnprintf vsprintf vsscanf vsscanf_s vswprintf vswprintf_s vswscanf vswscanf_s vwprintf vwprintf_s vwscanf vwscanf_s wprintf wprintf_s wscanf wscanf_s Localization support lconv LC_ALL LC_COLLATE LC_CTYPE LC_MONETARY LC_NUMERIC LC_TIME localeconv Localization support setlocale Numerics abs acos acosf acosh acoshf acoshl acosl asin asinf asinh asinhf asinhl asinl atan atan2 atan2f atan2l atanf atanh atanhf atanhl atanl cabs cabsf cabsl cacos cacosf cacosh cacoshf cacoshl cacosl carg cargf cargl casin casinf casinh casinhf casinhl casinl catan catanf catanh catanhf catanhl catanl cbrt cbrtf cbrtl ccos ccosf ccosh ccoshf ccoshl ccosl ceil ceilf ceill cexp cexpf cexpl cimag cimagf cimagl clog clogf clogl CMPLX CMPLXF CMPLXL Common mathematical functions complex Complex number arithmetic conj conjf conjl copysign copysignf copysignl cos cosf cosh coshf coshl cosl cpow cpowf cpowl cproj cprojf cprojl creal crealf creall csin csinf csinh csinhf csinhl csinl csqrt csqrtf csqrtl ctan ctanf ctanh ctanhf ctanhl ctanl div double_t erf erfc erfcf erfcl erff erfl exp exp2 exp2f exp2l expf expl expm1 expm1f expm1l fabs fabsf fabsl fdim feclearexcept fegetenv fegetexceptflag fegetround feholdexcept feraiseexcept fesetenv fesetexceptflag fesetround fetestexcept feupdateenv FE_ALL_EXCEPT FE_DFL_ENV FE_DIVBYZERO FE_DOWNWARD FE_INEXACT FE_INVALID FE_OVERFLOW FE_TONEAREST FE_TOWARDZERO FE_UNDERFLOW FE_UPWARD Floating-point environment float_t floor floorf floorl fma fmaf fmal fmax fmaxf fmaxl fmin fminf fminl fmod fmodf fmodl fpclassify FP_INFINITE FP_NAN FP_NORMAL FP_SUBNORMAL FP_ZERO frexp frexpf frexpl HUGE_VAL HUGE_VALF HUGE_VALL hypot hypotf hypotl I ilogb ilogbf ilogbl imaginary imaxabs imaxdiv INFINITY isfinite isgreater isgreaterequal isinf isless islessequal islessgreater isnan isnormal isunordered labs ldexp ldexpf ldexpl ldiv lgamma lgammaf lgammal llabs lldiv llrint llrintf llrintl llround llroundf llroundl log log10 log10f log10l log1p log1pf log1pl log2 log2f log2l logb logbf logbl logf logl lrint lrintf lrintl lround lroundf lroundl MATH_ERREXCEPT math_errhandling MATH_ERRNO modf modff modfl nan NAN nanf nanl nearbyint nearbyintf nearbyintl nextafter nextafterf nextafterl nexttoward nexttowardf nexttowardl Numerics pow powf powl Pseudo-random number generation rand RAND_MAX remainder remainderf remainderl remquo remquof remquol rint rintf rintl round roundf roundl scalbln scalblnf scalblnl scalbn scalbnf scalbnl signbit sin sinf sinh sinhf sinhl sinl sqrt sqrtf sqrtl srand tan tanf tanh tanhf tanhl tanl tgamma tgammaf tgammal trunc truncf truncl Type-generic math _Complex_I _Imaginary_I Program support abort atexit at_quick_exit exit EXIT_FAILURE EXIT_SUCCESS getenv getenv_s jmp_buf longjmp Program support utilities quick_exit raise setjmp SIGABRT SIGFPE SIGILL SIGINT signal SIGSEGV SIGTERM sig_atomic_t SIG_DFL SIG_ERR SIG_IGN system _Exit Strings atof atoi atol atoll btowc c16rtomb c32rtomb char16_t char32_t isalnum isalpha isblank iscntrl isdigit isgraph islower isprint ispunct isspace isupper iswalnum iswalpha iswblank iswcntrl iswctype iswdigit iswgraph iswlower iswprint iswpunct iswspace iswupper iswxdigit isxdigit mblen mbrlen mbrtoc16 mbrtoc32 mbrtowc mbsinit mbsrtowcs mbsrtowcs_s mbstate_t mbstowcs mbstowcs_s mbtowc memchr memcmp memcpy memcpy_s memmove memmove_s memset memset_s Null-terminated byte strings Null-terminated multibyte strings Null-terminated wide strings strcat strcat_s strchr strcmp strcoll strcpy strcpy_s strcspn strerror strerrorlen_s strerror_s Strings library strlen strncat Thread support call_once cnd_broadcast cnd_destroy cnd_init cnd_signal cnd_timedwait cnd_wait mtx_destroy mtx_init mtx_lock mtx_plain mtx_recursive mtx_timed mtx_timedlock mtx_trylock mtx_unlock once_flag ONCE_FLAG_INIT thrd_busy thrd_create thrd_current thrd_detach thrd_equal thrd_error thrd_exit thrd_join thrd_nomem thrd_sleep thrd_success thrd_timedout thrd_yield Thread support library thread_local tss_create tss_delete TSS_DTOR_ITERATIONS tss_get tss_set Type support Boolean type support library Fixed width integer types FLT_EVAL_METHOD FLT_ROUNDS max_align_t NULL Numeric limits offsetof ptrdiff_t size_t Type support Variadic functions Variadic functions va_arg va_copy va_end va_list va_start
characters

Defined in header <stdio.h>




(1)


int vprintf( const char *format, va_list vlist );

(until C99)


int vprintf( const char *restrict format, va_list vlist );

(since C99)



(2)


int vfprintf( FILE *stream, const char *format, va_list vlist );

(until C99)


int vfprintf( FILE *restrict stream, const char *restrict format,                va_list vlist );

(since C99)



(3)


int vsprintf( char *buffer, const char *format, va_list vlist );

(until C99)


int vsprintf( char *restrict buffer, const char *restrict format,                va_list vlist );

(since C99)


int vsnprintf( char *restrict buffer, int bufsz,                 const char *restrict format, va_list vlist );

(4)

(since C99)

int vprintf_s( const char *restrict format, va_list arg);

(5)

(since C11)

int vfprintf_s( FILE *restrict stream, const char *restrict format,                 va_list arg);

(6)

(since C11)

int vsprintf_s( char *restrict buffer, rsize_t bufsz,                 const char *restrict format, va_list arg);

(7)

(since C11)

int vsnprintf_s(char *restrict buffer, rsize_t bufsz,                 const char * restrict format, va_list arg);

(8)

(since C11)

從定義的位置加載數(shù)據(jù)vlist,將它們轉(zhuǎn)換為等同字符串并將結(jié)果寫入各種接收器。

1)將結(jié)果寫入stdout

2)將結(jié)果寫入文件流stream。

3)將結(jié)果寫入字符串buffer

4)將結(jié)果寫入字符串buffer。最多的buf_size字符是寫入的。結(jié)果字符串將以空字符結(jié)尾,除非buf_size為零。如果buf_size為零,則不會寫入任何內(nèi)容,并且buffer可能是空指針,但返回值(將寫入的字節(jié)數(shù))仍然會計算并返回。

5-8)與(1-4)相同,只是在運行時檢測到以下錯誤并調(diào)用當前安裝的約束處理函數(shù):

  • 轉(zhuǎn)換說明符%n存在于format

  • 任何對應的參數(shù)%s都是空指針

  • format或者buffer是空指針

  • bufsz 是零或大于 RSIZE_MAX

  • 編碼錯誤出現(xiàn)在任何字符串和字符轉(zhuǎn)換說明符中

  • vsprintf_s僅限于),要存儲的字符串buffer(包括結(jié)尾空值))將被超出bufsz

由于所有的邊界檢查功能,vprintf_s,vfprintf_s,vsprintf_s,和vsnrintf_s僅保證可供如果__STDC_LIB_EXT1__由實現(xiàn)所定義,并且如果用戶定義__STDC_WANT_LIB_EXT1__的整數(shù)常數(shù)1,包括之前<stdio.h>

參數(shù)

-

輸出文件流寫入




































































































































緩沖

-

指向要寫入的字符串的指針




































































































































bufsz

-

最多bufsz  - 可能會寫入1個字符,再加上空終止符




































































































































格式

-

指向以空字符結(jié)尾的字符串的指針,指定如何解釋數(shù)據(jù)。格式字符串由普通的多字節(jié)字符(%除外)組成,它們被原樣復制到輸出流和轉(zhuǎn)換規(guī)范中。每個轉(zhuǎn)換規(guī)范具有以下格式:介紹%字符(可選)一個或多個標志,用于修改轉(zhuǎn)換的行為: - :轉(zhuǎn)換結(jié)果在字段內(nèi)左對齊(默認情況下,它是右對齊的)+ :帶符號轉(zhuǎn)換的符號總是作為轉(zhuǎn)換結(jié)果的前綴(默認情況下,只有當結(jié)果為負時,結(jié)果才以負值開頭)space:如果帶符號轉(zhuǎn)換的結(jié)果不是以符號字符開頭,或者是空的,空間是預先考慮的結(jié)果。如果存在+標志,則忽略它。#:執(zhí)行轉(zhuǎn)換的替代形式。請參閱下表以了解確切的效果,否則行為未定義。0:對于整數(shù)和浮點數(shù)轉(zhuǎn)換,前導零用于填充字段而不是空格字符。對于整數(shù),如果明確指定了精度,它將被忽略。對于使用此標志的其他轉(zhuǎn)換會導致未定義的行為。如果 - 標志存在,它將被忽略。(可選)整數(shù)值或*指定最小字段寬度。如果需要,結(jié)果會填充空格字符(默認情況下),右側(cè)對齊時填充空白字符,左側(cè)填充右側(cè)填充。在使用*的情況下,寬度由類型為int的附加參數(shù)指定。如果參數(shù)的值是負值,那么結(jié)果是指定 - 標志和正字段寬度。(注意:這是最小寬度:該值從不被截斷。)(可選)。后跟整數(shù)或*,或者兩者都不指定轉(zhuǎn)換的精度。在使用*的情況下,精度由類型為int的附加參數(shù)指定。如果這個參數(shù)的值是負數(shù),它將被忽略。如果既不使用數(shù)字也不使用*,則精度取為零。請參閱下表以了解精確度的確切影響。(可選)長度修飾符,用于指定參數(shù)轉(zhuǎn)換格式說明符的大小以下格式說明符可用:轉(zhuǎn)換說明符說明參數(shù)類型長度修飾符hh(C99)。h(無)ll(C99)。j(C99)。z(C99)。t(C99)。L%寫文字%。完整的轉(zhuǎn)換規(guī)范必須是%%。不適用不適用不適用不適用不適用不適用不適用不適用不適用單個字符。該參數(shù)首先轉(zhuǎn)換為無符號字符。如果使用l修飾符,則首先將參數(shù)轉(zhuǎn)換為字符串,就好像通過具有wchar_t2參數(shù)的%ls一樣。N / AN / A int wint_t N / AN / AN / AN / AN / A s寫入字符串參數(shù)必須是指向字符數(shù)組的初始元素的指針。Precision指定要寫入的最大字節(jié)數(shù)。如果未指定Precision,則將每個字節(jié)寫入并不包括第一個空終止符。如果使用l說明符,則參數(shù)必須是指向wchar_t數(shù)組的初始元素的指針,該數(shù)組轉(zhuǎn)換為char數(shù)組,就好像通過調(diào)用具有零初始化轉(zhuǎn)換狀態(tài)的wcrtomb一樣。N / AN / A char * wchar_t * N / AN / AN / AN / AN / A di將有符號整數(shù)轉(zhuǎn)換為十進制表示形式-dddd。精度指定出現(xiàn)的最小位數(shù)。默認精度為1.如果轉(zhuǎn)換值和精度均為0,則轉(zhuǎn)換不會生成任何字符。signed char short int long long long intmax_t signed size_t ptrdiff_t不適用o將無符號整數(shù)轉(zhuǎn)換為八進制表示oooo。精度指定出現(xiàn)的最小位數(shù)。默認精度為1.如果轉(zhuǎn)換值和精度均為0,則轉(zhuǎn)換不會生成任何字符。在替代實現(xiàn)中,如果需要,可以增加精度以寫入一個前導零。在這種情況下,如果轉(zhuǎn)換值和精度均為0,則寫入單個0。unsigned char unsigned short unsigned int unsigned long unsigned long long uintmax_t size_t ptrdiff_t的無符號版本不適用x X將無符號整數(shù)轉(zhuǎn)換為十六進制表示形式hhhh。對于x轉(zhuǎn)換字母abcdef被使用。對于X轉(zhuǎn)換字母使用ABCDEF。精度指定出現(xiàn)的最小位數(shù)。默認精度為1.如果轉(zhuǎn)換值和精度均為0,則轉(zhuǎn)換不會生成任何字符。在替代實現(xiàn)中,如果轉(zhuǎn)換后的值為非零值,則0x或0X將作為結(jié)果的前綴。不適用u將無符號整數(shù)轉(zhuǎn)換為十進制表示形式dddd。精度指定出現(xiàn)的最小位數(shù)。默認精度為1.如果轉(zhuǎn)換值和精度均為0,則轉(zhuǎn)換不會生成任何字符。N / A f F將浮點數(shù)轉(zhuǎn)換為樣式-ddd.ddd中的十進制表示法。精度指定小數(shù)點后面出現(xiàn)的最小位數(shù)。默認精度為6.在替代實現(xiàn)中,即使沒有數(shù)字跟隨,小數(shù)點字符也會被寫入。對于無限和非數(shù)字轉(zhuǎn)換風格,請參閱注釋。N / AN / A double double(C99)N / AN / AN / AN / A long double e E將浮點數(shù)轉(zhuǎn)換為十進制指數(shù)表示法。對于e轉(zhuǎn)換樣式,使用-d.ddde±dd。對于E轉(zhuǎn)換樣式,使用-d.dddE±dd。指數(shù)至少包含兩位數(shù)字,只有在必要時才使用更多數(shù)字。如果該值為0,則指數(shù)也為0。精度指定小數(shù)點后面出現(xiàn)的最小位數(shù)。默認精度為6.在替代實現(xiàn)中,即使沒有數(shù)字跟隨,小數(shù)點字符也會被寫入。對于無限和非數(shù)字轉(zhuǎn)換風格,請參閱注釋。不適用不適用不適用不適用不適用不適用(C99)。將浮點數(shù)轉(zhuǎn)換為十六進制指數(shù)表示法。對于轉(zhuǎn)換類型,使用-0xh.hhhp±d。對于A轉(zhuǎn)換樣式,使用-0Xh.hhhP±d。如果參數(shù)不是標準化的浮點值,則第一個十六進制數(shù)字為0。如果該值為0,則指數(shù)也為0。精度指定小數(shù)點后面出現(xiàn)的最小位數(shù)。默認精度足以精確表示值。在替代實現(xiàn)中,即使沒有數(shù)字跟隨,小數(shù)點字符也會被寫入。對于無限和非數(shù)字轉(zhuǎn)換風格,請參閱注釋。不可用/不可用/不可用/不可用/ g G根據(jù)值和精度將浮點數(shù)轉(zhuǎn)換為十進制或十進制指數(shù)符號。對于使用樣式e或f的g轉(zhuǎn)換樣式轉(zhuǎn)換將被執(zhí)行。對于G轉(zhuǎn)換樣式,將使用樣式E或F進行轉(zhuǎn)換。假設(shè)P等于非零的精度,如果未指定精度,則等于6;如果精度為0,則等于1。然后,如果具有樣式E的轉(zhuǎn)換將具有X的指數(shù):如果P> X≥-4,則轉(zhuǎn)換具有樣式f或F和精度P-1-X。否則,轉(zhuǎn)換具有樣式e或E以及精度P  -  1.除非要求替代表示,否則尾隨零將被刪除,如果沒有剩余小數(shù)部分,小數(shù)點字符也會被刪除。對于無限和非數(shù)字轉(zhuǎn)換風格,請參閱注釋。不適用不適用不適用不適用不適用不適用不適用不適用不適用不適用不適用不適用不適用不適用不適用不適用不適用不適用不適用不適用不適用不適用不適用不適用不適用不適用不適用不適用不適用不適用不適用不適用不適用不適用不適用不適用不適用不適用不適用不適用不適用不適用 結(jié)果寫入?yún)?shù)指向的值。規(guī)范可能不包含任何標志,字段寬度或精度。signed char * short * int * long * long long * intmax_t * signed size_t * ptrdiff_t * N / A p寫一個實現(xiàn)定義的字符序列來定義一個指針。不適用不適用不適用不適用不適用不適用不適用浮點轉(zhuǎn)換函數(shù)將無窮大轉(zhuǎn)換為inf或無窮大。使用哪一個是實現(xiàn)定義的。非數(shù)字轉(zhuǎn)換為南或南(char_sequence)。使用哪一個是實現(xiàn)定義的。轉(zhuǎn)換F,E,G,A代替輸出INF,INFINITY,NAN。盡管%c需要int參數(shù),但因為在調(diào)用可變參數(shù)函數(shù)時發(fā)生整數(shù)提升,所以傳遞char是安全的。固定寬度字符類型(int8_t等)的正確轉(zhuǎn)換規(guī)范在標頭<inttypes.h>中定義(盡管PRIdMAX,PRIuMAX等與%jd,%ju等同義)。內(nèi)存寫入轉(zhuǎn)換說明符%n是格式字符串依賴用戶輸入并且不受邊界檢查的printf_s系列函數(shù)支持的安全漏洞的常見目標。每個轉(zhuǎn)換說明符的操作之后都有一個序列點; 這允許在同一個變量中存儲多個%n個結(jié)果,或者,作為邊界案例,在同一個調(diào)用中打印由較早的%n修改的字符串。如果轉(zhuǎn)換規(guī)范無效,則行為未定義。由于在調(diào)用可變參數(shù)函數(shù)時發(fā)生整數(shù)提升,所以傳遞char是安全的。固定寬度字符類型(int8_t等)的正確轉(zhuǎn)換規(guī)范在標頭<inttypes.h>中定義(盡管PRIdMAX,PRIuMAX等與%jd,%ju等同義)。內(nèi)存寫入轉(zhuǎn)換說明符%n是格式字符串依賴用戶輸入并且不受邊界檢查的printf_s系列函數(shù)支持的安全漏洞的常見目標。每個轉(zhuǎn)換說明符的操作之后都有一個序列點; 這允許在同一個變量中存儲多個%n個結(jié)果,或者,作為邊界案例,在同一個調(diào)用中打印由較早的%n修改的字符串。如果轉(zhuǎn)換規(guī)范無效,則行為未定義。由于在調(diào)用可變參數(shù)函數(shù)時發(fā)生整數(shù)提升,所以傳遞char是安全的。固定寬度字符類型(int8_t等)的正確轉(zhuǎn)換規(guī)范在標頭<inttypes.h>中定義(盡管PRIdMAX,PRIuMAX等與%jd,%ju等同義)。內(nèi)存寫入轉(zhuǎn)換說明符%n是格式字符串依賴用戶輸入并且不受邊界檢查的printf_s系列函數(shù)支持的安全漏洞的常見目標。每個轉(zhuǎn)換說明符的操作之后都有一個序列點; 這允許在同一個變量中存儲多個%n個結(jié)果,或者,作為邊界案例,在同一個調(diào)用中打印由較早的%n修改的字符串。如果轉(zhuǎn)換規(guī)范無效,則行為未定義。

轉(zhuǎn)換說明符

說明

參數(shù)類型

長度修飾符

hh(C99)。

H

(沒有)

(C99)。

j(C99)。

來自(C99)。

t(C99)。

%

寫文字%。完整的轉(zhuǎn)換規(guī)范必須是%%。

N / A

N / A

N / A

N / A

N / A

N / A

N / A

N / A

N / A

C

寫一個字符。該參數(shù)首先轉(zhuǎn)換為無符號字符。如果使用l修飾符,則首先將參數(shù)轉(zhuǎn)換為字符串,就好像通過具有wchar_t2參數(shù)的%ls一樣。

N / A

N / A

INT

所述wint_t

N / A

N / A

N / A

N / A

N / A

小號

writes a character string  The argument must be a pointer to the initial element of an array of characters. Precision specifies the maximum number of bytes to be written. If Precision is not specified, writes every byte up to and not including the first null terminator. If the l specifier is used, the argument must be a pointer to the initial element of an array of wchar_t, which is converted to char array as if by a call to wcrtomb with zero-initialized conversion state.

N/A

N/A

char*

wchar_t*

N/A

N/A

N/A

N/A

N/A

d i

converts a signed integer into decimal representation -dddd.  Precision specifies the minimum number of digits to appear. The default precision is 1. If both the converted value and the precision are 0 the conversion results in no characters.

signed char

short

int

long

long long

intmax_t

signed size_t

ptrdiff_t

N/A

o

converts a unsigned integer into octal representation oooo.  Precision specifies the minimum number of digits to appear. The default precision is 1. If both the converted value and the precision are 0 the conversion results in no characters. In the alternative implementation precision is increased if necessary, to write one leading zero. In that case if both the converted value and the precision are 0, single 0 is written.

unsigned char

unsigned short

unsigned int

unsigned long

unsigned long long

uintmax_t

size_t

unsigned version of ptrdiff_t

N/A

x X

converts an unsigned integer into hexadecimal representation hhhh.  For the x conversion letters abcdef are used. For the X conversion letters ABCDEF are used. Precision specifies the minimum number of digits to appear. The default precision is 1. If both the converted value and the precision are 0 the conversion results in no characters. In the alternative implementation 0x or 0X is prefixed to results if the converted value is nonzero.

N/A

u

converts an unsigned integer into decimal representation dddd.  Precision specifies the minimum number of digits to appear. The default precision is 1. If both the converted value and the precision are 0 the conversion results in no characters.

N/A

f F

converts floating-point number to the decimal notation in the style -ddd.ddd.  Precision specifies the minimum number of digits to appear after the decimal point character. The default precision is 6. In the alternative implementation decimal point character is written even if no digits follow it. For infinity and not-a-number conversion style see notes.

N/A

N/A

double

double (C99)

N/A

N/A

N/A

N/A

long double

e  E

converts floating-point number to the decimal exponent notation.  For the e conversion style -d.ddde±dd is used. For the E conversion style -d.dddE±dd is used. The exponent contains at least two digits, more digits are used only if necessary. If the value is 0, the exponent is also 0. Precision specifies the minimum number of digits to appear after the decimal point character. The default precision is 6. In the alternative implementation decimal point character is written even if no digits follow it. For infinity and not-a-number conversion style see notes.

N/A

N/A

N/A

N/A

N/A

N/A

a  A (C99).

converts floating-point number to the hexadecimal exponent notation.  For the a conversion style -0xh.hhhp±d is used. For the A conversion style -0Xh.hhhP±d is used. The first hexadecimal digit is 0 if the argument is not a normalized floating point value. If the value is 0, the exponent is also 0. Precision specifies the minimum number of digits to appear after the decimal point character. The default precision is sufficient for exact representation of the value. In the alternative implementation decimal point character is written even if no digits follow it. For infinity and not-a-number conversion style see notes.

N/A

N/A

N/A

N/A

N/A

N/A

g  G

converts floating-point number to decimal or decimal exponent notation depending on the value and the precision.  For the g conversion style conversion with style e or f will be performed. For the G conversion style conversion with style E or F will be performed. Let P equal the precision if nonzero, 6 if the precision is not specified, or 1 if the precision is 0. Then, if a conversion with style E would have an exponent of X:   if P > X ≥ ?4, the conversion is with style f or F and precision P ? 1 ? X.   otherwise, the conversion is with style e or E and precision P ? 1.   Unless alternative representation is requested the trailing zeros are removed, also the decimal point character is removed if no fractional part is left. For infinity and not-a-number conversion style see notes.

N/A

N/A

N/A

N/A

N/A

N/A

n

將此調(diào)用到目前為止寫入的字符數(shù)返回給該函數(shù)。結(jié)果寫入?yún)?shù)指向的值。規(guī)范可能不包含任何標志,字段寬度或精度。

簽名字符*

短*

INT *

long*

很長*

*將intmax_t

簽名size_t *

ptrdiff_t的*

N / A

p

寫一個實現(xiàn)定義的字符序列來定義一個指針。

N / A

N / A

無效*

N / A

N / A

N / A

N / A

N / A

N / A

轉(zhuǎn)換說明符

說明

參數(shù)類型




































































































































長度修飾符

hh(C99)。

H

(沒有)

(C99)。

j(C99)。

來自(C99)。

t(C99)。





























































































































%

寫文字%。完整的轉(zhuǎn)換規(guī)范必須是%%。

N / A

N / A

N / A

N / A

N / A

N / A

N / A

N / A

N / A




























































































































C

寫一個字符。該參數(shù)首先轉(zhuǎn)換為無符號字符。如果使用l修飾符,則首先將參數(shù)轉(zhuǎn)換為字符串,就好像通過具有wchar_t2參數(shù)的%ls一樣。

N / A

N / A

INT

所述wint_t

N / A

N / A

N / A

N / A

N / A




























































































































小號

寫入字符串參數(shù)必須是指向字符數(shù)組的初始元素的指針。Precision指定要寫入的最大字節(jié)數(shù)。如果未指定Precision,則將每個字節(jié)寫入并不包括第一個空終止符。如果使用l說明符,則參數(shù)必須是指向wchar_t數(shù)組的初始元素的指針,該數(shù)組轉(zhuǎn)換為char數(shù)組,就好像通過調(diào)用具有零初始化轉(zhuǎn)換狀態(tài)的wcrtomb一樣。

N / A

N / A

字符*

wchar_t的*

N / A

N / A

N / A

N / A

N / A




























































































































將有符號的整數(shù)轉(zhuǎn)換為十進制表示形式-dddd。精度指定出現(xiàn)的最小位數(shù)。默認精度為1.如果轉(zhuǎn)換值和精度均為0,則轉(zhuǎn)換不會生成任何字符。

簽名字符

INT

long

漫長的

還會將intmax_t

簽名size_t

ptrdiff_t的

N / A




























































































































將無符號整數(shù)轉(zhuǎn)換為八進制表示oooo。精度指定出現(xiàn)的最小位數(shù)。默認精度為1.如果轉(zhuǎn)換值和精度均為0,則轉(zhuǎn)換不會生成任何字符。在替代實現(xiàn)中,如果需要,可以增加精度以寫入一個前導零。在這種情況下,如果轉(zhuǎn)換值和精度均為0,則寫入單個0。

無符號字符

無符號短

無符號整數(shù)

無符號長整數(shù)

無符號long long

uintmax_t型

為size_t

未簽名的ptrdiff_t版本

N / A




























































































































x X

將無符號整數(shù)轉(zhuǎn)換為十六進制表示hhhh。對于x轉(zhuǎn)換字母abcdef被使用。對于X轉(zhuǎn)換字母使用ABCDEF。精度指定出現(xiàn)的最小位數(shù)。默認精度為1.如果轉(zhuǎn)換值和精度均為0,則轉(zhuǎn)換不會生成任何字符。在替代實現(xiàn)中,如果轉(zhuǎn)換后的值為非零值,則0x或0X將作為結(jié)果的前綴。

N / A




































































































































將無符號整數(shù)轉(zhuǎn)換為十進制表示形式dddd。精度指定出現(xiàn)的最小位數(shù)。默認精度為1.如果轉(zhuǎn)換值和精度均為0,則轉(zhuǎn)換不會生成任何字符。

N / A




































































































































f

將浮點數(shù)轉(zhuǎn)換為樣式-ddd.ddd中的小數(shù)表示法。精度指定小數(shù)點后面出現(xiàn)的最小位數(shù)。默認精度為6.在替代實現(xiàn)中,即使沒有數(shù)字跟隨,小數(shù)點字符也會被寫入。對于無窮大和非數(shù)字轉(zhuǎn)換風格,請參閱注釋。

N / A

N / A

雙(C99)

N / A

N / A

N / A

N / A

長雙




























































































































和E

將浮點數(shù)轉(zhuǎn)換為十進制指數(shù)符號。對于e轉(zhuǎn)換樣式,使用-d.ddde±dd。對于E轉(zhuǎn)換樣式,使用-d.dddE±dd。指數(shù)至少包含兩位數(shù)字,只有在必要時才使用更多數(shù)字。如果該值為0,則指數(shù)也為0。精度指定小數(shù)點后面出現(xiàn)的最小位數(shù)。默認精度為6.在替代實現(xiàn)中,即使沒有數(shù)字跟隨,小數(shù)點字符也會被寫入。對于無窮大和非數(shù)字轉(zhuǎn)換風格,請參閱注釋。

N / A

N / A

N / A

N / A

N / A

N / A































































































































A(C99)。

將浮點數(shù)轉(zhuǎn)換為十六進制指數(shù)表示法。對于轉(zhuǎn)換類型,使用-0xh.hhhp±d。對于A轉(zhuǎn)換樣式,使用-0Xh.hhhP±d。如果參數(shù)不是標準化的浮點值,則第一個十六進制數(shù)字為0。如果該值為0,則指數(shù)也為0。精度指定小數(shù)點后面出現(xiàn)的最小位數(shù)。默認精度足以精確表示值。在替代實現(xiàn)中,即使沒有數(shù)字跟隨它,也會寫入小數(shù)點字符。對于無窮大和非數(shù)字轉(zhuǎn)換風格,請參閱注釋。

N / A

N / A

N / A

N / A

N / A

N / A































































































































g G

根據(jù)值和精度將浮點數(shù)轉(zhuǎn)換為十進制或十進制指數(shù)符號。對于使用樣式e或f的g轉(zhuǎn)換樣式轉(zhuǎn)換將被執(zhí)行。對于G轉(zhuǎn)換樣式,將使用樣式E或F進行轉(zhuǎn)換。假設(shè)P等于非零的精度,如果未指定精度,則等于6;如果精度為0,則等于1。然后,如果具有樣式E的轉(zhuǎn)換將具有X的指數(shù):如果P> X≥-4,則轉(zhuǎn)換具有樣式f或F和精度P-1-X。否則,轉(zhuǎn)換具有樣式e或E以及精度P  -  1.除非要求替代表示,否則尾隨零將被刪除,如果沒有剩余小數(shù)部分,小數(shù)點字符也會被刪除。對于無窮大和非數(shù)字轉(zhuǎn)換風格,請參閱注釋。

N / A

N / A

N / A

N / A

N / A

N / A































































































































?

將此調(diào)用到目前為止寫入的字符數(shù)返回給該函數(shù)。結(jié)果寫入?yún)?shù)指向的值。規(guī)范可能不包含任何標志,字段寬度或精度。

簽名字符*

短*

INT *

long*

很長*

*將intmax_t

簽名size_t *

ptrdiff_t的*

N / A




























































































































p

寫一個實現(xiàn)定義的字符序列來定義一個指針。

N / A

N / A

無效*

N / A

N / A

N / A

N / A

N / A

N / A




























































































































VLIST

-

包含要打印的數(shù)據(jù)的變量參數(shù)列表




































































































































返回值

1-3)如果發(fā)生錯誤,則寫入的字符數(shù)如果成功或為負值。

4)如果發(fā)生錯誤,則成功寫入字符數(shù)或?qū)懭胴撝?。如果由?code>buf_size限制而導致結(jié)果字符串被截斷,則函數(shù)將返回如果未施加該限制的情況下將被寫入的字符總數(shù)(不包括終止空字節(jié))。

5,6)傳輸?shù)捷敵隽鞯淖址麛?shù)或負值(如果發(fā)生輸出錯誤,運行時間約束違規(guī)錯誤或編碼錯誤)。

7)寫入的字符數(shù)buffer,不包括空字符(只要buffer不是空指針,bufsz并且不為零且不大于RSIZE_MAX),則不計入空字符,或者在運行時約束違規(guī)時為零,編碼錯誤為負值

8)不包括終止空字符的字符數(shù)(只要buffer不是空指針并且bufsz不為零且不大于RSIZE_MAX),buffer如果bufsz被忽略,將被寫入的字符數(shù)或者如果運行時約束違規(guī)或編碼錯誤發(fā)生

注意

所有這些函數(shù)va_arg至少調(diào)用一次,arg返回后的值是不確定的。這些函數(shù)不會調(diào)用va_end,并且它必須由調(diào)用者完成。

vsnprintf_s不像vsprintf_s,會截斷結(jié)果以適應指向的數(shù)組buffer。

#include <stdio.h>#include <stdarg.h>#include <time.h> void debug_log(const char *fmt, ...){
    struct timespec ts;    timespec_get(&ts, TIME_UTC);
    char time_buf[100];
    size_t rc = strftime(time_buf, sizeof time_buf, "%D %T", gmtime(&ts.tv_sec));    snprintf(time_buf + rc, sizeof time_buf - rc, ".%06ld UTC", ts.tv_nsec / 1000);
 
    va_list args1;    va_start(args1, fmt);
    va_list args2;    va_copy(args2, args1);
    char buf[1+vsnprintf(NULL, 0, fmt, args1)];    va_end(args1);    vsnprintf(buf, sizeof buf, fmt, args2);    va_end(args2); 
    printf("%s [debug]: %s\n", time_buf, buf);}
 int main(void){    debug_log("Logging, %d, %d, %d", 1, 2, 3);}

可能的輸出:

02/20/15 21:58:09.072683 UTC [debug]: Logging, 1, 2, 3
Previous article: Next article: