#include<stdio.h>
#include<stdlib.h>
#define LEN sizeof(struct Worker)
struct Worker
{
int num;
char name[20];
float pay;
};
main()
{
int i;
struct Worker *p;
float f;
printf(“请输入一个实型数:”);
scanf("%f",&f);
p=(struct Worker*)malloc(LEN);
printf(“请输入一名工人的编号、名字和工资:\n”);
scanf("%d%s%f",&p->num,p->name,&p->pay);
printf(“员工信息为:\n”);
printf("%d %s %0.1f\n",p->num,p->name,p->pay);
free(p); /*释放已申请的空间*/
p=(struct Worker*)malloc(2*LEN);/*重新申请2个Worker大小的空间,并用p指向它*/
printf(“请输入两名工人的编号、名字和工资:\n”);
scanf("%d%s%f",&p->num,p->name,&p->pay);
scanf("%d%s%f",&(p+1)->num,(p+1)->name,&(p+1)->pay);
printf(“员工信息为:\n”);
printf("%d %s %0.1f\n",p->num,p->name,p->pay);
printf("%d %s %0.1f\n",(p+1)->num,(p+1)->name,(p+1)->pay);
free(p);
}