《c语言中各数据类型在内存中的存储方式》由会员分享,可在线阅读,更多相关《c语言中各数据类型在内存中的存储方式(5页珍藏版)》请在人人文库网上搜索。
1、c语言中各数据类型在内存中的存储方式基本的数据类型有:int 4long 4short 2signed char 1unsigned char 1unsigned long 4unsigned short 2float 4double 8基本为:char 1字节short 2字节int 4字节long 4字节float 4字节double 8字节typedef structchar ;char ;short ;charcharshort 类型的结构体占4字节内存。 char char 2字节 short 2字节typedef structshort;char;char;Short char c。
2、har 类型的结构体占4字节内存. short 2字节 char char 2字节typedef structchar ;short ;char ;csc;Char short char 类型的结构提占6字节内存,以short 做2字节对齐 char null 2字节 short 2字节 char null 2字节typedef structdouble ;char ;char ;char ;double char char char 类型的结构体占16字节内存8字节 double 8字节 char char char null typedef structchar ;char ;double。
3、 ;char ;char ;char ;char char double char char 类型的结构体占24字节内存8字节 使用2字节空余6字节 char char null 8字节 double 8字节 使用3字节空余5字节 char char char null typedef structchar ;int ;double;char ;char ;char ;int ;char int double char char char int 类型的结构体占用24字节内存8字节 使用2字节空余6字节 char null int 8字节 double 8字节 使用3字节空余5字节 char 。
4、char char null int typedef structchar ;short ;int ;double ;char ;int ;float ;char short int double char int float 类型的结构体占用32字节内存8字节 使用2字节空余6字节 char null short int 8字节 double 8字节 使用3字节空余5字节 char null int 8字节 使用3字节空余5字节 float null 对上一个结构体做位置变更,查看内存占用情况typedef structchar ;char ;short ;int ;int ;float ;double ;经过位置变更,占用内存为24字节 char char short int int float double typedef structshort ;char ;char ;char ;int ;short char char char int 类型的结构体占用12字节内存4字节 short char char 4字节 使用1字节剩余3字节 char null 4字节 int。