小白请教一下代码错误
我的代码,编译没报错,但运行就失败,自查看不出来哪有问题,请求路过的大佬指点指点。
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define stu struct Stu
//静态链表
struct Stu {
int xh;
char name[128];
int Cnsoe;
struct Stu *next;
};
void ChainTableJc(struct Stu* p) {
for(; p !=NULL; p++){
p->next = p;
}
}
void FenshuoShuru(stu* p, int len){
int i;
for(i=0; i<len; i++){
printf("请输入个人信息,学号、姓名、分数:");
scanf_s("%d %s %d", (p+i)->xh, (p+i)->name, (p+i)->Cnsoe);
printf("第%d个学生的信息:学号:%d\n姓名:%s\n语文分数%d\n", &(p+i)->xh, &(p+i)->name, &(p+i)->Cnsoe);
}
}
int main()
{
stu a, *head, *p;
int lenth = sizeof(a);
int nbr = 3;
head = &a;
head = (struct Stu* )calloc(nbr, lenth);
p = head;
ChainTableJc(p);
free(p);
FenshuoShuru(head, nbr);
system("pause");
return 0;
}
先在这里跪谢各位了。