// 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