首页 > 代码库 > P162

P162

#include<string.h>
#include<stdio.h>
main()
{
	struct objects{
		char name[20];
		int size;
		char color[10];
		float weight;
		float height;
		};
		struct objects obj1;
		struct objects *p;
		p=&obj1;
		strcpy(obj1.name,"pen");
		obj1.size=10;
		strcpy(obj1.color,"black");
		obj1.weight=50.5;
		obj1.height=18.5;
		printf("name:%s\nsize:%d\ncolor:%s\nweight:%f\nheight:%f\n",obj1.name,obj1.size,obj1.color,obj1.weight,obj1.height);
		printf("name:%s\nsize:%d\ncolor:%s\nweight:%f\nheight:%f\n",(*p).name,(*p).size,(*p).color,(*p).weight,(*p).height);
	
}