为什么在第一个for循环中循环一次后就无法继续循环了呢?
程序代码:
#include<stdio.h> #include<malloc.h> struct Student { char name[100]; int age; float score; }; int main(void) { int len; int i; struct Student *p; p=(struct Student *)malloc(len*sizeof(struct Student)); printf("请输入一共有几位学生:"); scanf("%d",&len); for(i=0;i<len;++i) { printf("请输入第%d位同学的信息:\n",i+1); printf("name:"); scanf("%s",p[i].name); printf("age:"); scanf("%f",&p[i].age); printf("score:"); scanf("%g",&p[i].score); } for(i=0;i<len;++i) { printf("请输出第%d位同学的信息:\n",i+1); printf("name:\n",p[i].name); printf("age:\n",&p[i].age); printf("score:\n",&p[i].score); } return 0; }