OC中char/short/int/float/double在64位系統中所佔位元組數
阿新 • • 發佈:2019-01-22
size_t charSize = sizeof(char); NSLog(@"charSize = %zu", charSize); size_t shortSize = sizeof(short); NSLog(@"shortSize = %zu", shortSize); size_t intSize = sizeof(int); NSLog(@"intSize = %zu", intSize); size_t floatSize = sizeof(float); NSLog(@"floatSize = %zu", floatSize); size_t doubleSize = sizeof(double); NSLog(@"doubleSize = %zu", doubleSize);
列印結果如下:
2017-03-31 21:37:47.747874 Sizeof[19698:1349743] charSize = 1 2017-03-31 21:37:47.748010 Sizeof[19698:1349743] shortSize = 2 2017-03-31 21:37:47.748022 Sizeof[19698:1349743] intSize = 4 2017-03-31 21:37:47.748031 Sizeof[19698:1349743] floatSize = 4 2017-03-31 21:37:47.748040 Sizeof[19698:1349743] doubleSize = 8