牧羊人nacy
基于你的代码修改之后,如下:/#includestruct men{int num;char name[8];char sex[8];float score;}boy[5];void input(){int i;for(i=0;i<5;i++){printf("Input the number:\n");scanf("%d",&boy[i].num);printf("Input the name:\n");scanf("%s",boy[i].name);printf("Input the sex:\n");scanf("%s",boy[i].sex);printf("Input the score:\n");scanf("%f",&boy[i].score);}}void output(){int i;for(i=0;i<5;i++){printf("NUM\t\t\tNAME\t\t\tSEX\t\t\tSCORE\n\n");printf("%d\t\t\t",boy[i].num);printf("%s\t\t\t",boy[i].name);printf("%c\t\t\t",boy[i].sex);printf("%.2f\n",boy[i].score);}}int main(){void input();void output();input();output();return (0);}//你之前出错的原因是,struct men里面的name你用的是指针,而你的代码中scanf("%s",boy[i].name);相当于把你输入的字符加载到boy[i].name这个char指针指向的单元;但是这个单元的大小你根本没有设置,所以编译器就报错咯。另外类别我也扩容了。/更新。。。我再自己的电脑上运行了一遍,IDE是Microsoft Visual Studio 9.0你要是要是有问题就问我。我放假了有时间,呵呵。