
void print();
这两句代码有问题。
void只有在函数声明的时候才用。
你得name只是个指针,没有内存空间,会溢出
给你跑通了,你看看吧
#include "stdio.h"#define N 100
struct stud{
int length;
int num;
char name[10];
int s1;
int s2;
int s3;
int sum;
};
struct stud st[N];
int Number = 0; //人数
void scan(struct stud *p){
int flog=0;
p->length=0;
while(flog!=-1)
{
printf("pess number,pess -1 stop\n");
scanf("%d",&flog);
if(flog!=-1)
p->num=flog;
else
break;
printf("pess name\n");
scanf("%s",p->name);
printf("pess math\n");
scanf("%d",&(p->s1));
printf("pess English\n");
scanf("%d",&(p->s2));
printf("pess C\n");
scanf("%d",&(p->s3));
p->length++;
p++;
Number++;
}
//p= p-p->length;
}
void print(struct stud *p){
int i;
printf("num\tmane\tmath\tenglish\tC\tsum\n");
for(i=0;i
printf("%d\t",p->num);
printf("%s\t",p->name);
printf("%d\t",p->s1); printf("%d\t",p->s2);
printf("%d\t",p->s3);
printf("%d",p->sum);
printf("\n");
p++;
}
}
void main(){
// void scan();
// void print();
scan(st);
print(st);
}
printf("pess name\n");
scanf("%s",&p->name);
printf("pess math\n");
scanf("%d",&p->s[0]);
printf("pess english\n");
scanf("%d",&p->s[1]);
printf("pess C\n");
scanf("%d",&p->s[2]);