目录搜索
AlgorithmsAlgorithms(算法)bsearchbsearch_sqsortqsort_sAtomic operationsAtomic operations library(原子操作库)ATOMIC_*_LOCK_FREEatomic_compare_exchange_strongatomic_compare_exchange_strong_explicitatomic_compare_exchange_weakatomic_compare_exchange_weak_explicitatomic_exchangeatomic_exchange_explicitatomic_fetch_addatomic_fetch_add_explicitatomic_fetch_andatomic_fetch_and_explicitatomic_fetch_oratomic_fetch_or_explicitatomic_fetch_subatomic_fetch_sub_explicitatomic_fetch_xoratomic_fetch_xor_explicitatomic_flagatomic_flag_clearatomic_flag_clear_explicitATOMIC_FLAG_INITatomic_flag_test_and_setatomic_flag_test_and_set_explicitatomic_initatomic_is_lock_freeatomic_loadatomic_load_explicitatomic_signal_fenceatomic_storeatomic_store_explicitatomic_thread_fence(线程围栏)ATOMIC_VAR_INITkill_dependencymemory_order(内存排序)C keywordsauto(自动存储)break(跳出循环)C keywords(关键词)casecharconst(常量修饰符)continuedefault(预设运算式)dodouble(双精度浮点型)elseenum(枚举类型)extern(全局变量)float(浮点数)forfortrangoto(goto语句)if(if语句)inline(行内函式)intlong(长整型)register(寄存器变量)restrict( restrict类型限定符)returnshortsignedsizeof(sizeof运算符)static(静态变量)struct(结构体)switch(switch语句)typedef(typedef关键字)union(联合体)unsigned(无符号)void(空类型)volatile(volatile变量)while(while语句)_Alignas_Alignof_Atomic_Bool_Complex_Generic_Imaginary_Noreturn_Static_assert_Thread_localC language#define directive#elif directive#else directive#endif directive#error directive#if directive#ifdef directive#ifndef directive#include directive#line directive#pragma directivealignas(对齐指定符)Alternative operators and tokens(替代运算符和令牌)AnalyzabilityArithmetic operatorsArithmetic typesArray declaration(数组声明)Array initialization(阵列初始化)ASCII ChartAssignment operators(赋值运算符)types(atomic类型限定符)Basic conceptsBit fields(位域)break statementC languageC Operator Precedencecast operatorcharacter constant(字符字面量)Comments(注释符)Comparison operators(比较运算符)compound literals(符合字面量)Conditional inclusion(条件包含)Conformance(一致性)const type qualifier(const 限定符)Constant expressions(常量表达)continue statementDeclarations(声明)do-while loopEnumerations(枚举类型)Escape sequences(转义字符)Expressions(表达式)External and tentative definitions(外部和暂定的定义)File scope(文件范围)floating constant(浮点常量)for loopFunction declarations(函数声明)Function definitions(函数声明)FunctionsGeneric selection泛型选择goto statementIdentifier(标示符)if statementImplicit conversions(隐式转换)Increment/decrement operators(前置/后置操作符)Initialization(初始化)inline function specifier(内联函式)integer constantLifetime(生命期)Logical operators(逻辑运算符)Lookup and name spacesMain function(主函式)Member access operators(会员接入运营商)Memory modelObjects and alignment(字节对齐)Order of evaluation(评估顺序)Other operatorsPhases of translation(翻译阶段)Pointer declarationPreprocessor(预处理)restrict type qualifier(restrict类型限定符)return statementScalar initialization(标量类型初始化)Scope(范围)sizeof operator(sizeof运算符)Statements(陈述)static assert declaration(静态断言声明)Static storage duration(静态存储周期)Storage-class specifiers(存储类说明符)string literals(字符串字面量)Struct and union initialization(结构体与联合体初始化)Struct declaration(结构体声明)switch statementThread storage duration(线程存储时间)TypeType(类型)Typedef declaration(Typedef声明)Undefined behavior(未定义行为)Union declaration(联合体声明)Value categories(值类别)Variadic arguments(变长参数宏)volatile type qualifier(volatile 类型限定符)while loop_Alignof operator_Noreturn function specifierDate and timeasctime(asctime函数)asctime_sclockCLOCKS_PER_SECclock_tctime(ctime函数)ctime_sDate and time utilities(日期和时间库)difftime(计算两个时间的间隔)gmtimegmtime_slocaltimelocaltime_smktime(将时间结构数据转换成经过的秒数的函数)strftime(格式化输出时间函数)timetimespectimespec_gettime_ttmwcsftime(格式化时间宽字符)Dynamic memory managementaligned_allocC memory management library(内存管理库)callocfree(释放动态分配空间的函数)malloc(动态分配内存空间的函数)realloc(重新分配内存空间的函数)Error handlingabort_handler_sassert(断言)constraint_handler_terrno(错误报告)Error handling(错误处理)Error numbers(错误个数)ignore_handler_sset_constraint_handler_sstatic_assertFile input/outputclearerr(清除/复位)fclosefeofferrorfflush(清空文件缓冲区)fgetcfgetposfgetsfgetwcfgetwsFile input/outputfopenfopen_sfprintffprintf_sfputcfputsfputwcfputwsfreadfreopenfreopen_sfscanffscanf_sfseekfsetposftellfwidefwprintffwprintf_sfwritefwscanffwscanf_sgetcgetchargetsgets_sgetwcharperrorprintfprintf_sputcputcharputsputwcputwcharremoverenamerewindscanfscanf_ssetbufsetvbufsnprintfsprintfsscanfsscanf_sswprintfswprintf_sswscanfswscanf_stmpfiletmpfile_stmpnamtmpnam_sungetcungetwcvfprintfvfprintf_svfscanfvfscanf_svfwprintfvfwprintf_svfwscanfvfwscanf_svprintfvprintf_svscanfvscanf_svsnprintfvsprintfvsscanfvsscanf_svswprintfvswprintf_svswscanfvswscanf_svwprintfvwprintf_svwscanfvwscanf_swprintfwprintf_swscanfwscanf_sLocalization supportlconvLC_ALLLC_COLLATELC_CTYPELC_MONETARYLC_NUMERICLC_TIMElocaleconvLocalization supportsetlocaleNumericsabsacosacosfacoshacoshfacoshlacoslasinasinfasinhasinhfasinhlasinlatanatan2atan2fatan2latanfatanhatanhfatanhlatanlcabscabsfcabslcacoscacosfcacoshcacoshfcacoshlcacoslcargcargfcarglcasincasinfcasinhcasinhfcasinhlcasinlcatancatanfcatanhcatanhfcatanhlcatanlcbrtcbrtfcbrtlccosccosfccoshccoshfccoshlccoslceilceilfceillcexpcexpfcexplcimagcimagfcimaglclogclogfcloglCMPLXCMPLXFCMPLXLCommon mathematical functionscomplexComplex number arithmeticconjconjfconjlcopysigncopysignfcopysignlcoscosfcoshcoshfcoshlcoslcpowcpowfcpowlcprojcprojfcprojlcrealcrealfcreallcsincsinfcsinhcsinhfcsinhlcsinlcsqrtcsqrtfcsqrtlctanctanfctanhctanhfctanhlctanldivdouble_terferfcerfcferfclerfferflexpexp2exp2fexp2lexpfexplexpm1expm1fexpm1lfabsfabsffabslfdimfeclearexceptfegetenvfegetexceptflagfegetroundfeholdexceptferaiseexceptfesetenvfesetexceptflagfesetroundfetestexceptfeupdateenvFE_ALL_EXCEPTFE_DFL_ENVFE_DIVBYZEROFE_DOWNWARDFE_INEXACTFE_INVALIDFE_OVERFLOWFE_TONEARESTFE_TOWARDZEROFE_UNDERFLOWFE_UPWARDFloating-point environmentfloat_tfloorfloorffloorlfmafmaffmalfmaxfmaxffmaxlfminfminffminlfmodfmodffmodlfpclassifyFP_INFINITEFP_NANFP_NORMALFP_SUBNORMALFP_ZEROfrexpfrexpffrexplHUGE_VALHUGE_VALFHUGE_VALLhypothypotfhypotlIilogbilogbfilogblimaginaryimaxabsimaxdivINFINITYisfiniteisgreaterisgreaterequalisinfislessislessequalislessgreaterisnanisnormalisunorderedlabsldexpldexpfldexplldivlgammalgammaflgammalllabslldivllrintllrintfllrintlllroundllroundfllroundlloglog10log10flog10llog1plog1pflog1pllog2log2flog2llogblogbflogbllogflogllrintlrintflrintllroundlroundflroundlMATH_ERREXCEPTmath_errhandlingMATH_ERRNOmodfmodffmodflnanNANnanfnanlnearbyintnearbyintfnearbyintlnextafternextafterfnextafterlnexttowardnexttowardfnexttowardlNumericspowpowfpowlPseudo-random number generationrandRAND_MAXremainderremainderfremainderlremquoremquofremquolrintrintfrintlroundroundfroundlscalblnscalblnfscalblnlscalbnscalbnfscalbnlsignbitsinsinfsinhsinhfsinhlsinlsqrtsqrtfsqrtlsrandtantanftanhtanhftanhltanltgammatgammaftgammaltrunctruncftrunclType-generic math_Complex_I_Imaginary_IProgram supportabortatexitat_quick_exitexitEXIT_FAILUREEXIT_SUCCESSgetenvgetenv_sjmp_buflongjmpProgram support utilitiesquick_exitraisesetjmpSIGABRTSIGFPESIGILLSIGINTsignalSIGSEGVSIGTERMsig_atomic_tSIG_DFLSIG_ERRSIG_IGNsystem_ExitStringsatofatoiatolatollbtowcc16rtombc32rtombchar16_tchar32_tisalnumisalphaisblankiscntrlisdigitisgraphislowerisprintispunctisspaceisupperiswalnumiswalphaiswblankiswcntrliswctypeiswdigitiswgraphiswloweriswprintiswpunctiswspaceiswupperiswxdigitisxdigitmblenmbrlenmbrtoc16mbrtoc32mbrtowcmbsinitmbsrtowcsmbsrtowcs_smbstate_tmbstowcsmbstowcs_smbtowcmemchrmemcmpmemcpymemcpy_smemmovememmove_smemsetmemset_sNull-terminated byte stringsNull-terminated multibyte stringsNull-terminated wide stringsstrcatstrcat_sstrchrstrcmpstrcollstrcpystrcpy_sstrcspnstrerrorstrerrorlen_sstrerror_sStrings librarystrlenstrncatThread supportcall_oncecnd_broadcastcnd_destroycnd_initcnd_signalcnd_timedwaitcnd_waitmtx_destroymtx_initmtx_lockmtx_plainmtx_recursivemtx_timedmtx_timedlockmtx_trylockmtx_unlockonce_flagONCE_FLAG_INITthrd_busythrd_createthrd_currentthrd_detachthrd_equalthrd_errorthrd_exitthrd_jointhrd_nomemthrd_sleepthrd_successthrd_timedoutthrd_yieldThread support librarythread_localtss_createtss_deleteTSS_DTOR_ITERATIONStss_gettss_setType supportBoolean type support libraryFixed width integer typesFLT_EVAL_METHODFLT_ROUNDSmax_align_tNULLNumeric limitsoffsetofptrdiff_tsize_tType supportVariadic functionsVariadic functionsva_argva_copyva_endva_listva_start
文字

Defined in header <wchar.h>




(1)


int vwprintf( const wchar_t *format, va_list vlist );

(since C95) (until C99)


int vwprintf( const wchar_t *restrict format, va_list vlist );

(since C99)



(2)


int vfwprintf( FILE* stream, const wchar_t *format, va_list vlist );

(since C95) (until C99)


int vfwprintf( FILE *restrict stream,                const wchar_t *restrict format, va_list vlist );

(since C99)



(3)


int vswprintf( wchar_t *buffer, size_t bufsz,                const wchar_t *format, va_list vlist );

(since C95) (until C99)


int vswprintf( wchar_t *restrict buffer, size_t bufsz,                const wchar_t *restrict format, va_list vlist );

(since C99)


int vwprintf_s( const wchar_t *restrict format, va_list vlist);

(4)

(since C11)

int vfwprintf_s( FILE * restrict stream,                  const wchar_t *restrict format, va_list vlist);

(5)

(since C11)

int vswprintf_s( wchar_t *restrict buffer, rsize_t bufsz,                   const wchar_t * restrict format, va_list vlist);

(6)

(since C11)

int vsnwprintf_s( wchar_t *restrict buffer, rsize_t bufsz,                   const wchar_t *restrict format, va_list vlist);

(7)

(since C11)

加载来自定义位置的数据vlist,将它们转换为宽字符串,并将结果写入各种接收器。

1)将结果写入stdout

2)将结果写入文件流stream

3)将结果写入一个宽字符串buffer。最bufsz-1宽字符后面跟着空宽字符。生成的宽字符串将以空宽字符结尾,除非bufsz为零。

4-7)与(1-3)相同,只是在运行时检测到以下错误并调用当前安装的约束处理函数:

  • 转换说明符%n存在于format

  • 任何对应的参数%s都是空指针

  • format或者buffer是空指针

  • bufsz 是零或大于 RSIZE_MAX/sizeof(wchar_t)

  • 编码错误出现在任何字符串和字符转换说明符中

  • vswprintf_s仅限于),要存储的字符串buffer(包括后面的宽空)将会超过bufsz

8)与(7)相同,除了它会截断结果以适应s所指向的数组。由于所有的边界检查功能,vwprintf_svfwprintf_svswprintf_s,和vsnwprintf_s仅保证可供如果__STDC_LIB_EXT1__由实现所定义,并且如果用户定义__STDC_WANT_LIB_EXT1__的整数常数1,包括之前<wchar.h>

参数

-

输出宽流写入




































































































































缓冲

-

指向要写入的宽字符串的指针




































































































































bufsz

-

要写入的最大宽字符数




































































































































格式

-

指向以空字符结尾的宽字符串的指针,指定如何解释数据。格式字符串由普通的宽字符(%除外)组成,它们被不变地复制到输出流中,以及转换规范。每个转换规范具有以下格式:介绍%字符(可选)一个或多个标志,用于修改转换的行为: - :转换结果在字段内左对齐(默认情况下,它是右对齐的)+ :带符号转换的符号总是作为转换结果的前缀(默认情况下,只有当结果为负时,结果才以负值开头)space:如果带符号转换的结果不是以符号字符开头,或者是空的,空间是预先考虑的结果。如果存在+标志,则忽略它。#:执行转换的替代形式。请参阅下表以了解确切的效果,否则行为未定义。0:对于整数和浮点数转换,前导零用于填充字段而不是空格字符。对于整数,如果明确指定了精度,它将被忽略。对于使用此标志的其他转换会导致未定义的行为。如果 - 标志存在,它将被忽略。(可选)整数值或*指定最小字段宽度。如果需要,结果会填充空格字符(默认情况下),右侧对齐时填充空白字符,左侧填充右侧填充。在使用*的情况下,宽度由类型为int的附加参数指定。如果参数的值是负值,那么结果是指定 - 标志和正字段宽度。(注意:这是最小宽度:该值从不被截断。)(可选)。后跟整数或*,或者两者都不指定转换的精度。在使用*的情况下,精度由类型为int的附加参数指定。如果这个参数的值是负数,它将被忽略。如果既不使用数字也不使用*,则精度取为零。请参阅下表以了解精确度的确切影响。(可选)长度修饰符,用于指定参数转换格式说明符的大小以下格式说明符可用:转换说明符说明参数类型长度修饰符hh(C99)。h(无)ll(C99)。j(C99)。z(C99)。t(C99)。L%写文字%。完整的转换规范必须是%%。不适用不适用不适用不适用不适用不适用不适用不适用不适用单个字符。该参数首先转换为wchar_t,就好像通过调用btowc一样。如果使用l修饰符,则首先将wint_t参数转换为wchar_t。N / AN / A int wint_t N / AN / AN / AN / AN / A s写入字符串参数必须是一个指向包含多字节字符序列的字符数组的初始元素的指针,该字符序列从初始转换状态开始,被转换为宽字符数组,就像通过调用mbrtowc以零初始化转换状态一样。Precision指定要写入的最大宽字符数。如果未指定Precision,则将每个宽字符写入并不包括第一个空终止符。如果使用l说明符,参数必须是指向wchar_t数组的初始元素的指针。N / AN / A char * wchar_t * N / AN / AN / AN / AN / A di将有符号整数转换为十进制表示形式-dddd。精度指定出现的最小位数。默认精度为1.如果转换值和精度均为0,则转换不会生成任何字符。signed char short int long long long intmax_t signed size_t ptrdiff_t不适用o将无符号整数转换为八进制表示oooo。精度指定出现的最小位数。默认精度为1.如果转换值和精度均为0,则转换不会生成任何字符。在替代实现中,如果需要,可以增加精度以写入一个前导零。在这种情况下,如果转换值和精度均为0,则写入单个0。unsigned char unsigned short unsigned int unsigned long unsigned long long uintmax_t size_t ptrdiff_t的无符号版本不适用x X将无符号整数转换为十六进制表示形式hhhh。对于x转换字母abcdef被使用。对于X转换字母使用ABCDEF。精度指定出现的最小位数。默认精度为1.如果转换值和精度均为0,则转换不会生成任何字符。在替代实现中,如果转换后的值为非零值,则0x或0X将作为结果的前缀。不适用u将无符号整数转换为十进制表示形式dddd。精度指定出现的最小位数。默认精度为1。如果转换值和精度均为0,则转换不会生成字符。N / A f F将浮点数转换为样式-ddd.ddd中的十进制表示法。精度指定小数点后面出现的最小位数。默认精度为6.在替代实现中,即使没有数字跟随,小数点字符也会被写入。对于无限和非数字转换风格,请参阅注释。N / AN / A double double(C99)N / AN / AN / AN / A long double e E将浮点数转换为十进制指数表示法。对于e转换样式,使用-d.ddde±dd。对于E转换样式,使用-d.dddE±dd。指数至少包含两位数字,只有在必要时才使用更多数字。如果该值为0,则指数也为0。精度指定小数点后面出现的最小位数。默认精度为6.在替代实现中,即使没有数字跟随,小数点字符也会被写入。对于无限和非数字转换风格,请参阅注释。不适用不适用不适用不适用不适用不适用(C99)。将浮点数转换为十六进制指数表示法。对于转换类型,使用-0xh.hhhp±d。对于A转换样式,使用-0Xh.hhhP±d。如果参数不是标准化的浮点值,则第一个十六进制数字为0。如果该值为0,则指数也为0。精度指定小数点后面出现的最小位数。默认精度足以精确表示值。在替代实现中,即使没有数字跟随,小数点字符也会被写入。对于无限和非数字转换风格,请参阅注释。不可用/不可用/不可用/不可用/ g G根据值和精度将浮点数转换为十进制或十进制指数符号。对于使用样式e或f的g转换样式转换将被执行。对于G转换样式,将使用样式E或F进行转换。假设P等于非零的精度,如果未指定精度,则等于6;如果精度为0,则等于1。然后,如果具有样式E的转换将具有X的指数:如果P> X≥-4,则转换具有样式f或F和精度P-1-X。否则,转换具有样式e或E以及精度P  -  1。除非请求替代表示,否则尾随零将被删除,如果没有剩余小数部分,小数点字符也会被删除。对于无限和非数字转换风格,请参阅注释。不适用不适用不适用不适用不适用不适用不适用不适用不适用不适用不适用不适用不适用不适用不适用不适用不适用不适用不适用不适用不适用不适用不适用不适用不适用不适用不适用不适用不适用不适用不适用不适用不适用不适用不适用不适用不适用不适用不适用不适用不适用不适用 结果写入参数指向的值。规范可能不包含任何标志,字段宽度或精度。signed char * short * int * long * long long * intmax_t * signed size_t * ptrdiff_t * N / A p写一个实现定义的字符序列来定义一个指针。不适用不适用不适用不适用不适用不适用不适用浮点转换函数将无穷大转换为inf或无穷大。使用哪一个是实现定义的。非数字转换为南或南(char_sequence)。使用哪一个是实现定义的。转换F,E,G,A代替输出INF,INFINITY,NAN。尽管%c需要int参数,但因为在调用可变参数函数时发生整数提升,所以传递char是安全的。固定宽度字符类型(int8_t等)的正确转换规范在标头<inttypes.h>中定义(尽管PRIdMAX,PRIuMAX等与%jd,%ju等同义)。内存写入转换说明符%n是格式字符串依赖用户输入并且不受边界检查的printf_s系列函数支持的安全漏洞的常见目标。每个转换说明符的操作之后都有一个序列点; 这允许将多个%n结果存储在相同的变量中,或者,作为边缘情况,在相同的调用中打印由早先的%n修改的字符串。如果转换规范无效,则行为未定义。

转换说明符

说明

参数类型

长度修饰符

hh(C99)。

H

(没有)

(C99)。

j(C99)。

来自(C99)。

t(C99)。

%

写文字%。完整的转换规范必须是%%。

N / A

N / A

N / A

N / A

N / A

N / A

N / A

N / A

N / A

C

写一个字符。该参数首先转换为wchar_t,就像调用btowc一样。如果使用l修饰符,则首先将wint_t参数转换为wchar_t。

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 a character array containing a multibyte character sequence beginning in the initial shift state, which is converted to wide character array as if by a call to mbrtowc with zero-initialized conversion state. Precision specifies the maximum number of wide characters to be written. If Precision is not specified, writes every wide characters 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.

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

将此调用到目前为止写入的字符数返回给该函数。结果写入参数指向的值。规范可能不包含任何标志,字段宽度或精度。

签名字符*

短*

INT *

long*

很长*

*将intmax_t

签名size_t *

ptrdiff_t的*

N / A

p

写一个实现定义的字符序列来定义一个指针。

N / A

N / A

无效*

N / A

N / A

N / A

N / A

N / A

N / A

转换说明符

说明

参数类型




































































































































长度修饰符

hh(C99)。

H

(没有)

(C99)。

j(C99)。

来自(C99)。

t(C99)。





























































































































%

写文字%。完整的转换规范必须是%%。

N / A

N / A

N / A

N / A

N / A

N / A

N / A

N / A

N / A




























































































































C

写一个字符。该参数首先转换为wchar_t,就像调用btowc一样。如果使用l修饰符,则首先将wint_t参数转换为wchar_t。

N / A

N / A

INT

所述wint_t

N / A

N / A

N / A

N / A

N / A




























































































































小号

写入字符串参数必须是指向包含从初始移位状态开始的多字节字符序列的字符数组的初始元素的指针,该字符序列将转换为宽字符数组,就好像通过调用mbrtowc进行零初始化转换状态。Precision指定要写入的最大宽字符数。如果未指定Precision,则将每个宽字符写入并不包括第一个空终止符。如果使用l说明符,则参数必须是指向wchar_t数组的初始元素的指针。

N / A

N / A

字符*

wchar_t的*

N / A

N / A

N / A

N / A

N / A




























































































































将有符号的整数转换为十进制表示形式-dddd。精度指定出现的最小位数。默认精度为1.如果转换值和精度均为0,则转换不会生成任何字符。

签名字符

INT

long

漫长的

还会将intmax_t

签名size_t

ptrdiff_t的

N / A




























































































































将无符号整数转换为八进制表示oooo。精度指定出现的最小位数。默认精度为1.如果转换值和精度均为0,则转换不会生成任何字符。在替代实现中,如果需要,可以增加精度以写入一个前导零。在这种情况下,如果转换值和精度均为0,则写入单个0。

无符号字符

无符号短

无符号整数

无符号长整数

无符号long long

uintmax_t型

为size_t

未签名的ptrdiff_t版本

N / A




























































































































x X

将无符号整数转换为十六进制表示hhhh。对于x转换字母abcdef被使用。对于X转换字母使用ABCDEF。精度指定出现的最小位数。默认精度为1.如果转换值和精度均为0,则转换不会生成任何字符。在替代实现中,如果转换后的值为非零值,则0x或0X将作为结果的前缀。

N / A




































































































































将无符号整数转换为十进制表示形式dddd。精度指定出现的最小位数。默认精度为1.如果转换值和精度均为0,则转换不会生成任何字符。

N / A




































































































































f

将浮点数转换为样式-ddd.ddd中的小数表示法。精度指定小数点后面出现的最小位数。默认精度为6.在替代实现中,即使没有数字跟随,小数点字符也会被写入。对于无穷大和非数字转换风格,请参阅注释。

N / A

N / A

双(C99)

N / A

N / A

N / A

N / A

长双




























































































































和E

将浮点数转换为十进制指数符号。对于e转换样式,使用-d.ddde±dd。对于E转换样式,使用-d.dddE±dd。指数至少包含两位数字,只有在必要时才使用更多数字。如果该值为0,则指数也为0。精度指定小数点后面出现的最小位数。默认精度为6.在替代实现中,即使没有数字跟随,小数点字符也会被写入。对于无穷大和非数字转换风格,请参阅注释。

N / A

N / A

N / A

N / A

N / A

N / A































































































































A(C99)。

将浮点数转换为十六进制指数表示法。对于转换类型,使用-0xh.hhhp±d。对于A转换样式,使用-0Xh.hhhP±d。如果参数不是标准化的浮点值,则第一个十六进制数字为0。如果该值为0,则指数也为0。精度指定小数点后面出现的最小位数。默认精度足以精确表示值。在替代实现中,即使没有数字跟随它,也会写入小数点字符。对于无穷大和非数字转换风格,请参阅注释。

N / A

N / A

N / A

N / A

N / A

N / A































































































































g G

根据值和精度将浮点数转换为十进制或十进制指数符号。对于使用样式e或f的g转换样式转换将被执行。对于G转换样式,将使用样式E或F进行转换。假设P等于非零的精度,如果未指定精度,则等于6;如果精度为0,则等于1。然后,如果具有样式E的转换将具有X的指数:如果P> X≥-4,则转换具有样式f或F和精度P-1-X。否则,转换具有样式e或E以及精度P  -  1.除非要求替代表示,否则尾随零将被删除,如果没有剩余小数部分,小数点字符也会被删除。对于无穷大和非数字转换风格,请参阅注释。

N / A

N / A

N / A

N / A

N / A

N / A































































































































ñ

将此调用到目前为止写入的字符数返回给该函数。结果写入参数指向的值。规范可能不包含任何标志,字段宽度或精度。

签名字符*

短*

INT *

long*

很长*

*将intmax_t

签名size_t *

ptrdiff_t的*

N / A




























































































































p

写一个实现定义的字符序列来定义一个指针。

N / A

N / A

无效*

N / A

N / A

N / A

N / A

N / A

N / A




























































































































VLIST

-

包含要打印的数据的变量参数列表




































































































































返回值

1-3)如果发生错误,则成功写入宽字符数或写入宽字符数。

4)如果发生错误,则成功写入宽字符数或写入宽字符数。如果由于bufsz限制而导致结果字符串被截断,则函数将返回如果未强加限制,则会写入的字符总数(不包括终止空宽字符)。

5,6)传输到输出流的宽字符数,如果发生输出错误,运行时约束违规错误或编码错误,则输出负值。

7)写入的宽字符数buffer,不包括空宽字符(只要buffer不是空指针,bufsz且不为零且不大于RSIZE_MAX/sizeof(wchar_t)),则为空宽字符,或者在运行时约束违规时为零,并且编码为负值错误

8)不包括终止空字符的宽字符数(只要buffer不是空指针bufsz且不为零且不大于RSIZE_MAX/sizeof(wchar_t)),buffer如果bufsz被忽略,则写入的宽字符数或负值if发生运行时约束违规或编码错误

注意

所有这些函数va_arg至少调用一次,arg返回后的值是不确定的。这些函数不会调用va_end,并且它必须由调用者完成。

虽然窄字符串提供了vsnprintf,这使得可以确定所需的输出缓冲区大小,但对于宽字符串没有等效(直到C11的vsnwprintf_s),并且为了确定缓冲区大小,程序可能需要调用vswprintf,检查结果值,并重新分配一个更大的缓冲区,再次尝试直到成功。

vsnwprintf_s不同vswprintf_s,将截断结果以适应指向的数组buffer,即使截断被大多数边界检查函数视为错误。

#include <stdio.h>#include <time.h>#include <locale.h> void debug_wlog(const wchar_t *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 args;    va_start(args, fmt);
    wchar_t buf[1000];
    int rc2 = vswprintf(buf, sizeof buf / sizeof *buf, fmt, args);    va_end(args); 
    if(rc2 > 0)       wprintf(L"%s [debug]: %ls\n", time_buf, buf);    else       wprintf(L"%s [debug]: (string too long)\n", time_buf);}
 int main(void){    setlocale(LC_ALL, "");    debug_wlog(L"Logging, %d, %d, %d", 1, 2, 3);}

可能的输出:

02/20/15 22:12:38.476575 UTC [debug]: Logging, 1, 2, 3
上一篇:下一篇: