前言
code
#include <stdio.h> #include <stdlib.h> #define Size 5 typedef struct Table{ char length; char size; char ss; int len; }table; table *t1=(table*)calloc(Size, sizeof(table)); int main() { printf("t1_0: %d\n", sizeof(t1)); printf("t1_1: %d\n", sizeof(*t1)); printf("t1_2: %d\n", sizeof(table)); printf("t1_3: %d\n", sizeof(t1)/sizeof(table)); printf("t1_4: %d\n", sizeof(*t1)/sizeof(table)); return 0; }View Code
每种数据类型在内存中所占内存大小与平台编译器有关。
参考
1. C语言各数据类型所占字节数;
2. C语言内存对齐(数据对齐);
完
标签:printf,数据类型,t1,table,对齐,sizeof,C语言 From: https://www.cnblogs.com/happyamyhope/p/16699530.html