標籤:c基礎資料型別 (Elementary Data Type)
先來張C資料類型的圖片,如
650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/45/D1/wKiom1PsFlbz4ROYAADPAyT_cBQ963.jpg" title="c資料類型.png" alt="wKiom1PsFlbz4ROYAADPAyT_cBQ963.jpg" />
基礎資料型別 (Elementary Data Type)的長度,資料存放區是以"位元組"(Byte)為單位,資料轉送是以"位"(bit)為單位,一位就代表一個0或1(二進位),一個位元組(Byte)佔8位(bit).
#import <Foundation/Foundation.h>int main(int argc, const char * argv[]){ @autoreleasepool { short int shortIntType = 1; int intType = 2; long longType = 3L; float floatType = 4.1f; double doubleType = 5; char charType = ‘A‘; printf("size of short it is %lu Byte\n",sizeof(shortIntType)); printf("size of int is %lu Byte\n",sizeof(intType)); printf("size of long is %lu Byte\n",sizeof(longType)); printf("size of float is %lu Byte\n",sizeof(floatType)); printf("size of double is %lu Byte\n",sizeof(doubleType)); printf("size of char is %lu Byte\n",sizeof(charType)); } return 0;}
輸出結果如:
650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/45/D3/wKioL1PsHariJP-nAACZhpcU_3k250.jpg" title="長度.png" alt="wKioL1PsHariJP-nAACZhpcU_3k250.jpg" />
本文出自 “7803002” 部落格,請務必保留此出處http://7813002.blog.51cto.com/7803002/1539769