Objective - c 데이터 길이

2959 단어 Objective-c
//  Created by chenyijun on 16/10/4.
//  Copyright (c) 2016  chenyijun. All rights reserved.
//

#import 

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        NSLog(@"char                            length ===== %ld
", sizeof(char)); NSLog(@"short int length ===== %ld
", sizeof(short int)); NSLog(@"unsigned short int length ===== %ld
", sizeof(unsigned short int)); NSLog(@"int length ===== %ld
", sizeof(int)); NSLog(@"unsigned int length ===== %ld
", sizeof(unsigned int)); NSLog(@"long int length ===== %ld
", sizeof(long int)); NSLog(@"unsigned long int length ===== %ld
", sizeof(unsigned long int)); NSLog(@"long long int length ===== %ld
", sizeof(long long int)); NSLog(@"unsigned long long int length ===== %ld
", sizeof(unsigned long long int)); NSLog(@"float length ===== %ld
", sizeof(float)); NSLog(@"double length ===== %ld
", sizeof(double)); NSLog(@"long double length ===== %ld
", sizeof(long double)); NSLog(@"id length ===== %ld
", 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

좋은 웹페이지 즐겨찾기