小弟才疏学浅,请T版赐教

认认真真的学习,踏踏实实的走路:戒骄戒躁!!!
2012-12-26 20:50
2012-12-26 20:51
2012-12-26 20:52
2012-12-26 20:53
2012-12-26 20:54
程序代码:
struct er
{
struct yi *boy[3];
}
程序代码:
struct er
{
struct yi boy[3];
}

2012-12-26 20:56
程序代码:#include<stdio.h>//错误啊
#include<stdlib.h>
struct yi
{
char name[10];
int age;
char address[20];
};
struct er
{
struct yi *boy[3];
};
void main()
{int i;
struct er *p;
p=(struct er*)malloc(sizeof(struct er));
p->boy[0]=(struct yi *)malloc(sizeof(struct yi)*3);
for(i=0;i<3;i++)
scanf("%s%d%s",(p->boy[0]+i)->name,&(p->boy[0]+i)->age,(p->boy[0]+i)->address);
for(i=0;i<3;i++)
printf("%s\t%d\t%s\n",(p->boy[0]+i)->name,(p->boy[0]+i)->age,(p->boy[0]+i)->address);
free(p->boy[0]);
free(p);
}另一种实现过程,今天刚跟别人学的,现学现卖

2012-12-26 20:58
struct er
{
struct yi boy[3];
}
2012-12-26 21:00
程序代码:
#include<stdio.h>//错误啊
#include<stdlib.h>
struct yi
{
char name[10];
int age;
char address[20];
};
struct er
{
struct yi boy[3];
};
void main()
{int i;
struct er *p;
p=(struct er*)malloc(sizeof(struct er));
for(i=0;i<3;i++)
scanf("%s%d%s",p->boy[i]->name,&p->boy[i]->age,p->boy[i]->address);
for(i=0;i<3;i++)
printf("%s\t%d\t%s\n",p->boy[i]->name,p->boy[i]->age,p->boy[i]->address);
}
2012-12-26 21:01

2012-12-26 21:02