oc 前缀格式
来源:互联网 发布:java二维码生成代码 编辑:程序博客网 时间:2024/04/29 11:20
The format specifiers supported by the NSString formatting methods and CFString formatting
functions follow the IEEE printf specification; the specifiers are summarized in Table 1.
Note that you can also use the “n$” positional specifiers such as %1$@ %2$s.
For more details, see the IEEE printf specification. You can also use these format specifiers with the NSLog function.
Mac OS X uses several data types—NSInteger, NSUInteger,CGFloat, and CFIndex—to provide a
consistent means of representing values in 32- and 64-bit environments. In a 32-bit environment,
NSInteger and NSUInteger are defined as int and unsigned int, respectively. In 64-bit environments,
NSInteger and NSUInteger are defined as long and unsigned long, respectively. To avoid the need to
use different printf-style type specifiers depending on the platform, you can use the specifiers shown
in Table 2. Note that in some cases you may have to cast the value.
The following example illustrates the use of %ld to format an NSInteger and the use of a cast.
2
printf("%ld\n", (long)i);
In addition to the considerations mentioned in Table 2, there is one extra case with scanning:
you must distinguish the types for float and double. You should use %f for float, %lf for double.
If you need to use scanf (or a variant thereof) with CGFloat, switch to double instead, and copy the double to CGFloat.
2
3
4
double tmp;
sscanf (str, "%lf", &tmp);
imageWidth = tmp;
It is important to remember that %lf does not represent CGFloat correctly on either 32- or 64-bit platforms.
This is unlike %ld, which works for long in all cases.
基本数据类型
1. int
输出格式符:%i, %d, %o %x,
2. float
输出格式符:%f, %e, %g
3. double
输出格式符:%f, %e, %g
4. char
输出格式符:%c
限定符:
1. long
long int: %li
long double: %Lf
形成long int通过在数字后面加L.
long int number = 123324123234123L;
2. long long
long long int: %lli
3. short
short int: %hi
4. unsigned
5. signed
它们各自所占的字节数
#import<Foundation/Foundation.h>
int main (int argc,const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePoolalloc] init];
NSLog(@"The size of an int is: %d bytes.",sizeof(int));
NSLog(@"The size of a short int is: %d bytes.",sizeof(shortint));
NSLog(@"The size of a long int is: %d bytes.",sizeof(longint));
NSLog(@"The size of a char is: %d bytes.",sizeof(char));
NSLog(@"The size of a float is: %d bytes.",sizeof(float));
NSLog(@"The size of a double is: %d bytes.",sizeof(double));
NSLog(@"The size of a bool is: %d bytes.",sizeof(bool));
[pool drain];
return 0;
}
2011-08-21 09:29:16.475 sizeofTest[860:903] The size of an int is: 4 bytes.
2011-08-21 09:29:16.478 sizeofTest[860:903] The size of a short int is: 2 bytes.
2011-08-21 09:29:16.478 sizeofTest[860:903] The size of a long int is: 8 bytes.
2011-08-21 09:29:16.479 sizeofTest[860:903] The size of a char is: 1 bytes.
2011-08-21 09:29:16.479 sizeofTest[860:903] The size of a float is: 4 bytes.
2011-08-21 09:29:16.479 sizeofTest[860:903] The size of a double is: 8 bytes.
2011-08-21 09:29:16.480 sizeofTest[860:903] The size of a bool is: 1 bytes.
logout
- oc 前缀格式
- OC的NS前缀
- 前缀格式和后缀格式
- oc NSLog 输出格式
- OC常见输出格式符
- OC时间格式转换方法
- OC 自定义 setDateFormat 显示格式
- OC中NSLog输出格式
- OC 自定义 setDateFormat 显示格式
- OC的NSLog输出格式
- OC开发中前缀命名的一些细节
- python学习笔记-批量添加OC文件前缀
- NS前缀\OC中的注释\访问OC原文件、C原文件中的函数
- 前缀
- 前缀
- .Net服务端Soap接口返回xml的前缀格式问题
- OC中NSLog函数输出格式详解
- OC中NSLog函数输出格式详解
- ASP.NET安装部署问题总结
- 双链表的相关操作
- System.getProperty
- 形容女子的佳句
- 无病呻吟系列
- oc 前缀格式
- 浅谈过载保护
- 一致性哈希(Consistent Hashing)
- 什么是复合视频信号(CVBS)
- 来电归属、来电隐身?你归隐吧!
- android viewflipper 左右滑动切换显示图片效果
- 谁知道在openswan 网关对网关,中间有NAT设备下,这是什么问题呀?
- Google检索技巧
- (转)red5视频聊天源码