亚洲国产日韩欧美一区二区三区,精品亚洲国产成人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(關鍵詞) case char const(常量修飾符) continue default(預設運算式) 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關鍵字) 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

在頭文件<stdio.h>中定義




(1)


int printf(const char * format,...);

(直到C99)


int printf(const char * restrict format,...);

(自C99以來)



(2)


int fprintf(FILE * stream,const char * format,...);

(直到C99)


int fprintf(FILE * restrict stream,const char * restrict format,...);

(自C99以來)



(3)


int sprintf(char * buffer,const char * format,...);

(直到C99)


int sprintf(char * restrict buffer,const char * restrict format,...);

(自C99以來)


int snprintf(char *限制緩沖區(qū),int bufsz,const char *限制格式,...);

(4)

(自C99以來)

int printf_s(const char * restrict format,...);

(5)

(自C11以來)

int fprintf_s(FILE * restrict stream,const char * restrict format,...);

(6)

(自C11以來)

int sprintf_s(char * restrict buffer,rsize_t bufsz,const char * restrict format,...);

(7)

(自C11以來)

int snprintf_s(char * restrict buffer,rsize_t bufsz,const char * restrict format,...);

(8)

(自C11以來)

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

1)將結(jié)果寫入輸出流stdout。

2)將結(jié)果寫入輸出流stream。

3)將結(jié)果寫入字符串buffer。如果要寫入的字符串(加上終止的空字符)超過了指向的數(shù)組的大小,則行為未定義buffer。

4)將結(jié)果寫入字符串buffer。最多bufsz- 寫入1個字符。結(jié)果字符串將以空字符結(jié)尾,除非bufsz為零。如果bufsz為零,則不會寫入任何內(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)換說明符中

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

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

參數(shù)

-

輸出文件流寫入




































































































































緩沖

-

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




































































































































bufsz

-

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




































































































































格式

-

pointer to a null-terminated multibyte string specifying how to interpret the data. The format string consists of ordinary multibyte characters (except %), which are copied unchanged into the output stream, and conversion specifications. Each conversion specification has the following format:   introductory % character   (optional) one or more flags that modify the behavior of the conversion:    -: the result of the conversion is left-justified within the field (by default it is right-justified)   +: the sign of signed conversions is always prepended to the result of the conversion (by default the result is preceded by minus only when it is negative)   space: if the result of a signed conversion does not start with a sign character, or is empty, space is prepended to the result. It is ignored if + flag is present.   # : alternative form of the conversion is performed. See the table below for exact effects otherwise the behavior is undefined.   0 : for integer and floating point number conversions, leading zeros are used to pad the field instead of space characters. For integer numbers it is ignored if the precision is explicitly specified. For other conversions using this flag results in undefined behavior. It is ignored if - flag is present.    (optional) integer value or * that specifies minimum field width. The result is padded with space characters (by default), if required, on the left when right-justified, or on the right if left-justified. In the case when * is used, the width is specified by an additional argument of type int. If the value of the argument is negative, it results with the - flag specified and positive field width. (Note: This is the minimum width: The value is never truncated.)    (optional) . followed by integer number or *, or neither that specifies precision of the conversion. In the case when * is used, the precision is specified by an additional argument of type int. If the value of this argument is negative, it is ignored. If neither a number nor * is used, the precision is taken as zero. See the table below for exact effects of precision.   (optional) length modifier that specifies the size of the argument   conversion format specifier           The following format specifiers are available:    Conversion specifier   Explanation   Argument type     length modifier   hh (C99).   h   (none)   l   ll (C99).   j (C99).   z (C99).   t (C99).   L     %   writes literal %. The full conversion specification must be %%.   N/A   N/A   N/A   N/A   N/A   N/A   N/A   N/A   N/A     c    writes a single character.  The argument is first converted to unsigned char. If the l modifier is used, the argument is first converted to a character string as if by %ls with a wchar_t2 argument.   N/A   N/A   int   wint_t   N/A   N/A   N/A   N/A   N/A     s    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   returns the number of characters written so far by this call to the function.  The result is written to the value pointed to by the argument. The specification may not contain any flag, field width, or precision.   signed char*   short*   int*   long*   long long*   intmax_t*   signed size_t*    ptrdiff_t*   N/A     p   writes an implementation defined character sequence defining a pointer.   N/A   N/A   void*   N/A   N/A   N/A   N/A   N/A   N/A    The floating point conversion functions convert infinity to inf or infinity. Which one is used is implementation defined. Not-a-number is converted to nan or nan(char_sequence). Which one is used is implementation defined. The conversions F, E, G, A output INF, INFINITY, NAN instead. Even though %c expects int argument, it is safe to pass a char because of the integer promotion that takes place when a variadic function is called. The correct conversion specifications for the fixed-width character types (int8_t, etc) are defined in the header <inttypes.h> (although PRIdMAX, PRIuMAX, etc is synonymous with %jd, %ju, etc). The memory-writing conversion specifier %n is a common target of security exploits where format strings depend on user input and is not supported by the bounds-checked printf_s family of functions. There is a sequence point after the action of each conversion specifier; this permits storing multiple %n results in the same variable or, as an edge case, printing a string modified by an earlier %n within the same call. If a conversion specification is invalid, the behavior is undefined.

Conversion specifier

Explanation

Argument type

length modifier

hh (C99).

h

(none)

l

ll (C99).

j (C99).

z (C99).

t (C99).

L

%

writes literal %. The full conversion specification must be %%.

N/A

N/A

N/A

N/A

N/A

N/A

N/A

N/A

N/A

c

writes a single character.  The argument is first converted to unsigned char. If the l modifier is used, the argument is first converted to a character string as if by %ls with a wchar_t2 argument.

N/A

N/A

int

wint_t

N/A

N/A

N/A

N/A

N/A

s

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

returns the number of characters written so far by this call to the function.  The result is written to the value pointed to by the argument. The specification may not contain any flag, field width, or precision.

signed char*

short*

int*

long*

long long*

intmax_t*

signed size_t*

ptrdiff_t*

N/A

p

writes an implementation defined character sequence defining a pointer.

N/A

N/A

void*

N/A

N/A

N/A

N/A

N/A

N/A

Conversion specifier

Explanation

Argument type




































































































































length modifier

hh (C99).

h

(none)

l

ll (C99).

j (C99).

z (C99).

t (C99).

L





























































































































%

writes literal %. The full conversion specification must be %%.

N/A

N/A

N/A

N/A

N/A

N/A

N/A

N/A

N/A




























































































































c

writes a single character.  The argument is first converted to unsigned char. If the l modifier is used, the argument is first converted to a character string as if by %ls with a wchar_t2 argument.

N/A

N/A

int

wint_t

N/A

N/A

N/A

N/A

N/A




























































































































s

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




























































































































...

-

指定要打印的數(shù)據(jù)的參數(shù)




































































































































  • 介紹%人物

  • (可選)一個或多個修改轉(zhuǎn)換行為的標志:

    • -:轉(zhuǎn)換的結(jié)果在字段內(nèi)左對齊(默認情況下它是右對齊的)

    • +:帶符號轉(zhuǎn)換的符號總是預設為轉(zhuǎn)換結(jié)果的前綴(默認情況下結(jié)果前面為減號,僅當它為負值時)

    • 空格:如果簽名轉(zhuǎn)換的結(jié)果不是以符號字符開頭,或者是空的,則空格會預設為結(jié)果。如果+存在標志,則忽略它。

    • #:執(zhí)行轉(zhuǎn)換的替代形式。請參閱下表以了解確切的效果,否則行為未定義。

    • 0:對于整數(shù)和浮點數(shù)轉(zhuǎn)換,前導零用于填充字段而不是空格字符。對于整數(shù),如果明確指定了精度,它將被忽略。對于使用此標志的其他轉(zhuǎn)換會導致未定義的行為。如果-存在標志,則忽略它。

  • (可選)整數(shù)值或*指定最小字段寬度。如果需要,結(jié)果會填充空格字符(默認情況下),右側(cè)對齊時填充空白字符,左側(cè)填充右側(cè)填充。在使用的情況下*,寬度由類型的附加參數(shù)指定int。如果參數(shù)的值是負數(shù),則結(jié)果是-指定的標志和正的字段寬度。(注意:這是最小寬度:該值從不被截斷。)

    • (可選).后面跟隨整數(shù)或者*或者既不指定轉(zhuǎn)換的精度。在使用的情況下*精度由類型的附加參數(shù)指定int。如果這個參數(shù)的值是負數(shù),它將被忽略。如果既不使用數(shù)字也不*使用,則精度取為零。請參閱下表以了解精確度的確切影響。

    • (可選)長度修飾符,用于指定參數(shù)的大小

    • 轉(zhuǎn)換格式說明符

以下格式說明符可用:

Conversion

說明符說明參數(shù)類型長度修飾符    hh(C99)。

h   (none)   l   ll (C99).

j (C99).

z (C99).

t (C99).

L %   寫文字%。完整的轉(zhuǎn)換規(guī)范必須是%%。N / AN / AN / AN / AN / AN / AN / AN / AN / A      c    寫入單個字符。該論點首先轉(zhuǎn)換為unsigned char。如果使用了l修飾符,則首先將參數(shù)轉(zhuǎn)換為字符串,就像通過具有參數(shù)的%ls一樣wchar_t[2]。

N/A   N/A   int

wint_t

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

N/A   N/A   char*

wchar_t*

N/A   N/A   N/A   N/A   N/A     d

i   將有符號的整數(shù)轉(zhuǎn)換為十進制表示形式-dddd。  精度指定出現(xiàn)的最小位數(shù)。默認的精度是1。

如果轉(zhuǎn)換后的值和精度都是0沒有字符的轉(zhuǎn)換結(jié)果。

signed char

short

int

long

long long

intmax_t

signed size_t

ptrdiff_t

N / A      o   將無符號整數(shù)轉(zhuǎn)換為八進制表示oooo。  精度指定出現(xiàn)的最小位數(shù)。默認的精度是1。如果轉(zhuǎn)換后的值和精度都是0沒有字符的轉(zhuǎn)換結(jié)果。在替代實現(xiàn)中,如果需要,可以增加精度以寫入一個前導零。在這種情況下,如果轉(zhuǎn)換值和精度都是00寫入單個。

unsigned char

unsigned short

unsigned int

unsigned long

unsigned 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)換結(jié)果。在替代實現(xiàn)中, 0x或者0X如果轉(zhuǎn)換后的值不為零,則將其作為結(jié)果的前綴。

N / A      u   將無符號整數(shù)轉(zhuǎn)換為十進制表示形式dddd。  精度指定出現(xiàn)的最小位數(shù)。默認的精度是1。如果轉(zhuǎn)換后的值和精度都是0沒有字符的轉(zhuǎn)換結(jié)果。

N/A     f

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

N/A   N/A   double

`double` (C99)

N/A   N/A   N/A   N/A   long double

 `e`

E   將浮點數(shù)轉(zhuǎn)換為十進制指數(shù)符號。對于e轉(zhuǎn)換樣式,使用-d.ddd e±dd。

對于E轉(zhuǎn)換樣式,使用-d.ddd E±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

A (C99).

浮點數(shù)轉(zhuǎn)換為十六進制指數(shù)表示法。對于a轉(zhuǎn)換樣式- 使用0xh.hhh p±d。

對于A轉(zhuǎn)換樣式- 使用0Xh.hhh P±d。

0如果參數(shù)不是標準化的浮點值,則第一個十六進制數(shù)字是。如果值是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ù)符號。對于風格轉(zhuǎn)換的轉(zhuǎn)換與風格或?qū)⒈粓?zhí)行。gef

對于G風格轉(zhuǎn)換的轉(zhuǎn)換與風格EF將被執(zhí)行。

P等于精度如果非零,6如果沒有指定精度,或者1如果精度是0。然后,如果具有樣式的轉(zhuǎn)換E將具有以下指數(shù)X

  • 如果P> X≥-4,轉(zhuǎn)換是用式fF和精度P - 1 - X。

  • 否則,轉(zhuǎn)換采用樣式eE精度P  -  1。

除非請求替代表示,否則尾隨零將被刪除,如果沒有剩余小數(shù)部分,小數(shù)點字符也會被刪除。對于無窮大和非數(shù)字轉(zhuǎn)換風格,請參閱注釋。

不適用/不適用/不適用/不適用/      n   返回此函數(shù)迄今為止寫入的字符數(shù)。結(jié)果寫入參數(shù)指向的值。規(guī)范可能不包含任何標志,字段寬度精度。

signed char*

short*

int*

long*

long long*

intmax_t*

size_t*

ptrdiff_t*

N / A      p   寫入一個實現(xiàn)定義的字符序列來定義一個指針。不適用不適用不適用不適用不適用不適用    void*   浮點轉(zhuǎn)換函數(shù)將無窮大轉(zhuǎn)換為infinfinity。使用哪一個是實現(xiàn)定義的。

非數(shù)字轉(zhuǎn)換為nan或。使用哪一個是實現(xiàn)定義的。nan(char_sequence)

該轉(zhuǎn)換F,E,G,A輸出INF,INFINITY,NAN來代替。

即使%c需要int參數(shù),通過char調(diào)用可變參數(shù)函數(shù)時發(fā)生的整數(shù)提升也是安全的。

對于固定寬度的字符類型(正確的轉(zhuǎn)換規(guī)格int8_t<inttypes.h>還(雖然,等等)都在頭定義PRIdMAX,PRIuMAX等是同義詞%jd,%ju等)。

內(nèi)存寫入轉(zhuǎn)換說明符%n是安全漏洞的常見目標,其中格式字符串取決于用戶輸入,并且不受邊界檢查printf_s函數(shù)族的支持。

每個轉(zhuǎn)換說明符的操作之后都有一個序列點; 這允許將多個%n結(jié)果存儲在相同的變量中,或者作為邊緣情況,%n在同一個調(diào)用中打印由較早修改的字符串。

如果轉(zhuǎn)換規(guī)范無效,則行為未定義。

 ...   -   arguments specifying data to print

返回值

1,2)發(fā)送到輸出流的字符數(shù)或負值(如果發(fā)生輸出錯誤或編碼錯誤(用于字符串和字符轉(zhuǎn)換說明符))

3)寫入的字符數(shù)buffer(不包括終止空字符);如果發(fā)生編碼錯誤(用于字符串和字符轉(zhuǎn)換說明符),則返回負值

4)buffer如果bufsz被忽略,將被寫入的字符數(shù)(不包括終止空字符),或者如果編碼錯誤(對于字符串和字符轉(zhuǎn)換說明符)發(fā)生,則為負值

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ā)生

注意

C標準和POSIX指定sprintf當參數(shù)與目標緩沖區(qū)重疊時,其行為及其變體未定義。例:

sprintf(dst, "%s and %s", dst, t); // <- broken: undefined behavior

POSIX指定該errno設置上的錯誤。它還指定了額外的轉(zhuǎn)換規(guī)范,最顯著的是支持參數(shù)重新排序(n$緊接在%指示n'th參數(shù)之后)。

snprintf使用零bufsz和空指針調(diào)用buffer對于確定包含輸出所需的緩沖區(qū)大小很有用:

const char *fmt = "sqrt(2) = %f";int sz = snprintf(NULL, 0, fmt, sqrt(2));char buf[sz + 1]; // note +1 for terminating null bytesnprintf(buf, sizeof buf, fmt, sqrt(2));

snprintf_s,就像snprintf,但不像sprintf_s,會截斷輸出以適應bufsz-1。

#include <stdio.h>
 int main(void){    printf("Strings:\n");    const char* s = "Hello";    printf("\t.%10s.\n\t.%-10s.\n\t.%*s.\n", s, s, 10, s); 
    printf("Characters:\t%c %%\n", 65); 
    printf("Integers\n");    printf("Decimal:\t%i %d %.6i %i %.0i %+i %u\n", 1, 2, 3, 0, 0, 4, -1);    printf("Hexadecimal:\t%x %x %X %#x\n", 5, 10, 10, 6);    printf("Octal:\t%o %#o %#o\n", 10, 10, 4); 
    printf("Floating point\n");    printf("Rounding:\t%f %.0f %.32f\n", 1.5, 1.5, 1.3);    printf("Padding:\t%05.2f %.2f %5.2f\n", 1.5, 1.5, 1.5);    printf("Scientific:\t%E %e\n", 1.5, 1.5);    printf("Hexadecimal:\t%a %A\n", 1.5, 1.5);}

輸出:

Strings:    .     Hello.    .Hello     .    .     Hello.Characters:     A %Integers
Decimal:        1 2 000003 0  +4 4294967295Hexadecimal:    5 a A 0x6Octal:          12 012 04Floating point
Rounding:       1.500000 2 1.30000000000000004440892098500626Padding:        01.50 1.50  1.50Scientific:     1.500000E+00 1.500000e+00Hexadecimal:    0x1.8p+0 0X1.8P+0

參考

  • C11標準(ISO / IEC 9899:2011):

    • 7.21.6.1 fprintf函數(shù)(p:309-316)

    • 7.21.6.3 printf函數(shù)(p:324)

    • 7.21.6.5 snprintf函數(shù)(p:325)

    • 7.21.6.6 sprintf函數(shù)(p:325-326)

    • K.3.5.3.1 fprintf_s函數(shù)(p:591)

    • K.3.5.3.3 printf_s函數(shù)(p:593-594)

    • K.3.5.3.5 snprintf_s函數(shù)(p:594-595)

    • K.3.5.3.6 sprintf_s函數(shù)(p:595-596)

  • C99標準(ISO / IEC 9899:1999):

    • 7.19.6.1 fprintf函數(shù)(p:274-282)

    • 7.19.6.3 printf函數(shù)(p:290)

    • 7.19.6.5 snprintf函數(shù)(p:290-291)

    • 7.19.6.6 sprintf函數(shù)(p:291)

  • C89 / C90標準(ISO / IEC 9899:1990):

    • 4.9.6.1 fprintf函數(shù)

    • 4.9.6.3 printf函數(shù)

    • 4.9.6.5 sprintf函數(shù)

Previous article: Next article: