Objective-C 常用数据类型
2011-08-21 01:08
453 查看
基本数据类型
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 alloc] init];
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
相关文章推荐
- Objective-C中基本数据烦类型与对象数据类型相互转换的方法(OC中NSString的常用API的基础应用3)
- Objective-C研究之常用数据类型
- Objective-C常用数据类型之间的转换
- [2]姥爷幽默谈Objective-C(getter,setter,init 方法、和类方法以及常用数据类型的介绍)
- 6.常用数据类型之objective-c
- 5. 18 Objective-C 常用数据类型(NSValue NSNumber NSString )的方法
- VC常用数据类型使用转换详解
- Linux下定义Windows常用数据类型
- PostgreSQL学习手册(常用数据类型)
- 关于format函数及数据类型的常用替换说明
- objective-c 中数据类型之五 数值类(NSNumber及NSNumberFormatter)
- VC++常用数据类型及其操作详解
- 黑马程序员——Objective-C程序设计(第4版)学习笔记之10-变量和数据类型——黑马 IOS 技术博客
- mysql-常用命令及数据类型
- Objective-C中的一些特殊的数据类型
- VC常用数据类型
- Objective-C代码的文件扩展名与数据类型
- 跟我学REDIS-REDIS(三)----常用数据类型之Hash
- redis数据类型以及常用的命令
- Oracle速查语法:数据类型,函数,异常类型,常用命令