ITeye博客

结构体

includemain · 2012-05-07 00:00 · C++ · C · 编程语言 · Markdown

#include <stdio.h>

struct Person {
	char i;
	char a[7];
	int no;
	int age;
};

struct Country {
	char i;
	int j;
	char k[7];
	int a;
};
void main() {

	struct Person p = {
		'a', "abcdef", 1, 20
	};
	
	struct Country c = {
		'a', 1, "abcdef", 20
	};
	printf("Person结构体占用的大小:%d\n", sizeof( struct Person ) );
	printf("Country结构体占用的大小:%d\n", sizeof( struct Country ) );
}

Person结构体占用的大小:16
Country结构体占用的大小:20

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。