专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > 移动开发

objective-c根本数据类型之输出格式符

发布时间:2010-05-30 05:29:13 文章来源:www.iduyao.cn 采编人员:星星草
objective-c基本数据类型之输出格式符

基本数据类型

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 = [[NSAutoreleasePool allocinit];

NSLog(@"The size of an int is: %d bytes.",sizeof(int));

NSLog(@"The size of a short int is: %d bytes.",sizeof(short int));

NSLog(@"The size of a long int is: %d bytes.",sizeof(long int));

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

 

转自:http://www.cnblogs.com/getsun/archive/2011/08/21/2147618.html

友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: