【问题标题】:iOS NSLog %hd %hhd %ld and %lld format specifiers [closed]iOS NSLog %hd %hhd %ld 和 %lld 格式说明符 [关闭]
【发布时间】:2013-07-25 09:51:51
【问题描述】:

这些格式说明符的含义是什么?

%hd %hhd %ld %lld

【问题讨论】:

标签: ios string-formatting nslog


【解决方案1】:

%hd 用于short integerunsigned short integer

%hhd 用于short short integerunsigned short short integer

%ld 用于long integerunsigned long integer

%lld 用于long long integerunsigned long long integer

就这么简单。

这里 hhhlll 只是 %d 中的长度修饰符

来源:http://developer.apple.com/library/ios/#documentation/cocoa/conceptual/Strings/Articles/formatSpecifiers.html

【讨论】:

  • 据我所知,没有short short int这样的东西。
  • 我知道,没有short short int这种东西,它只是一个char,它是C中最小的整数存储类。但我没有那么多时间向他解释+ 如果他想学习,我希望他阅读文档,而不仅仅是期待 SO 的答案。
【解决方案2】:
【解决方案3】:

我觉得 IBM 的 this document 好一点。所以:

  %hd       int x          (short)x           10     1
  %ld       long x         (long)x            10     1

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-12-31
  • 2011-12-28
  • 1970-01-01
  • 2011-05-23
  • 2016-07-27
  • 1970-01-01
  • 2012-05-17
相关资源
最近更新 更多