#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int N1,N2;
int n=0;
int y,n; //此处错误
struct course
{ int num1; //课程编号
char name1[20];
char major[20];
char type[20];
int credit;
int period;
char teacher[20];
int people; //选此门课程的人数
struct course *next; }; //结构体指针
struct student
{ int num2;
char name2[20];
int nelenum[50]; //所选课程编号
int nelen; //所选课程学分和
struct student * next; };
struct course * head1;
struct student * head2;
void zhang() //从键盘录入课程信息
{
struct course *p1,*p2;
N1=0;
p1=p2=(struct course *)malloc(sizeof(struct course));
int y,n;
if(n==0)
do
{
printf("--------------------\n");
printf("请输入课程编号:");
scanf("%d",&p1->num1);
printf("请输入课程名称:");
scanf("%s",p1->name1);
printf("请输入主修:");
scanf("%s",p1->major);
printf("请输入课程性质:");
scanf("%s",p1->type);
printf("请输入学分:");
scanf("%d",&p1->credit);
printf("请输入课时:");
scanf("%d",&p1->period);
printf("请输入教师名称:");
scanf("%s",p1->teacher);
n++;
p1++;
printf("\n1.继续输入.\n0.输入完毕.\n");
printf("请选择:");
scanf("%d",&y);
}
你已经定义了一个n,怎么又定义一个