Objective-c各数据长度

//  Created by chenyijun on 16/10/4.
//  Copyright (c) 2016年 chenyijun. All rights reserved.
//

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        NSLog(@"char                            length ===== %ld\n", sizeof(char));
        NSLog(@"short int                       length ===== %ld\n", sizeof(short int));
        NSLog(@"unsigned short int              length ===== %ld\n", sizeof(unsigned short int));
        NSLog(@"int                             length ===== %ld\n", sizeof(int));
        NSLog(@"unsigned int                    length ===== %ld\n", sizeof(unsigned int));
        NSLog(@"long int                        length ===== %ld\n", sizeof(long int));
        NSLog(@"unsigned long int               length ===== %ld\n", sizeof(unsigned long int));
        NSLog(@"long long int                   length ===== %ld\n", sizeof(long long int));
        NSLog(@"unsigned long long int          length ===== %ld\n", sizeof(unsigned long long int));
        NSLog(@"float                           length ===== %ld\n", sizeof(float));
        NSLog(@"double                          length ===== %ld\n", sizeof(double));
        NSLog(@"long double                     length ===== %ld\n", sizeof(long double));
        NSLog(@"id                              length ===== %ld\n", sizeof(id));
    }
    return 0;
}

运行结果

2016-10-04 16:08:50.751 practice10_06[914:26823] char                                      length ===== 1

2016-10-04 16:08:50.752 practice10_06[914:26823] short int                               length ===== 2

2016-10-04 16:08:50.752 practice10_06[914:26823] unsigned short int              length ===== 2

2016-10-04 16:08:50.752 practice10_06[914:26823] int                                         length ===== 4

2016-10-04 16:08:50.752 practice10_06[914:26823] unsigned int                        length ===== 4

2016-10-04 16:08:50.752 practice10_06[914:26823] long int                                length ===== 8

2016-10-04 16:08:50.752 practice10_06[914:26823] unsigned long int               length ===== 8

2016-10-04 16:08:50.752 practice10_06[914:26823] long long int                        length ===== 8

2016-10-04 16:08:50.752 practice10_06[914:26823] unsigned long long int       length ===== 8

2016-10-04 16:08:50.752 practice10_06[914:26823] float                                      length ===== 4

2016-10-04 16:08:50.752 practice10_06[914:26823] double                                  length ===== 8

2016-10-04 16:08:50.753 practice10_06[914:26823] long double                         length ===== 16

2016-10-04 16:08:50.753 practice10_06[914:26823] id                                          length ===== 8






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值