我试图理解以下 section :
l (ell)
Specifies that a following
d
,i
,o
,u
,x
, orX
conversion specifier applies to along
orunsigned long
argument; that a followingn
conversion specifier applies to a pointer to along
argument; that a followingc
conversion specifier applies to awint_t
argument; that a followings
conversion specifier applies to a pointer to awchar_t
argument; or has no effect on a followinga
,A
,e
,E
,f
,F
,g
, orG
conversion specifier.
我也可以看出这与cppreference:fprintf是一致的其中 "%f"
和 "%lf"
等同于 printf()
系列。
this answer也是如此错误的?还是 C99
明确指出 "%f"
用于 float
,而 "%lf"
用于对于 double
对于 printf()
系列函数?
最佳答案
文档是正确的:printf
认为 float
和 double
之间没有区别。
printf
系列函数的参数通过可变长度机制获取。在可变长度参数列表的可变长度部分,应用“默认参数提升”:类型 char
和 short int
被提升为 int
,float
被提升为 double
。
关于c - `l` 长度修饰符对后面的 a、A、e、E、f、F、g 或 G 转换说明符没有影响,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34528346/