不是说long long类型在微软操作系统下必须用%I64d来输出吗?为什么也可以用%lld来输出?

nikannishishui 2012-02-28 03:32:28
不是说long long类型在微软操作系统下必须用%I64d来输出吗?为什么在VC2010下也可以用%lld来输出?

long long x=9223372036854775807;
printf("%lld\n",x);

成功输出了:9223372036854775807
而DEV和CODE:BLOCKS则必须使用%I64d,用%lld输出的是long型的最大值,请问这是怎么回事?
...全文
275 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
赵4老师 2012-02-28
  • 打赏
  • 举报
回复
以下内容来自MSDN2005:
A format specification, which consists of optional and required fields, has the following form:

%[flags] [width] [.precision] [{h | l | ll | I | I32 | I64}]type

yiyefangzhou24 2012-02-28
  • 打赏
  • 举报
回复
long long?我怎么记得好像是用双精度浮点型输出的啊double输出64位大数
luciferisnotsatan 2012-02-28
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 nikannishishui 的回复:]

引用 1 楼 luciferisnotsatan 的回复:
vc里就是等价的。
MSDN里也这么写的

Size Prefixes for printf and wprintf Format-Type Specifiers
To specify Use prefix With type specifier
long int
l (lowercase L)
d, i, o, x, ……
[/Quote]
查得是vc2005的,之后的版本应该都是相等的了
nikannishishui 2012-02-28
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 luciferisnotsatan 的回复:]
vc里就是等价的。
MSDN里也这么写的

Size Prefixes for printf and wprintf Format-Type Specifiers
To specify Use prefix With type specifier
long int
l (lowercase L)
d, i, o, x, or X

long unsigned int
……
[/Quote]
哪个版本的MSDN这么写的啊,VC6.0里没有long long,vc2003估计只能用%I64d来输出long long,你说的应该是vc2010吧.
luciferisnotsatan 2012-02-28
  • 打赏
  • 举报
回复
vc里就是等价的。
MSDN里也这么写的

Size Prefixes for printf and wprintf Format-Type Specifiers
To specify Use prefix With type specifier
long int
l (lowercase L)
d, i, o, x, or X

long unsigned int
l
o, u, x, or X

long long
ll
d, i, o, x, or X

short int
h
d, i, o, x, or X

short unsigned int
h
o, u, x, or X

__int32
I32
d, i, o, x, or X

unsigned __int32
I32
o, u, x, or X

__int64
I64
d, i, o, x, or X

unsigned __int64
I64
o, u, x, or X

69,371

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧