我有一个循环结构数组,它接受用户输入的学生姓名和卷号
代码:
int x;
struct studs
{
char name[50];
char rollno[50];
}student[50];
printf("\t\t________________________________");
printf("\n\n\t\t\tStudent Registration");
printf("\n\t\t_______________________________");
printf("\n\n\tHow many students in %s ", course);
scanf("%d", &stud);
admin = fopen(name, "a");
fprintf(admin, "\nNumber of students for %s: %d", course, stud);
fclose(admin);
for(x=0; x<stud; x++)
{
printf("\n\nStudent %d", x+1);
printf("\n_____________________________");
printf("\n\nStudent Name : ");
scanf("%s", student[x].name);
printf("\nStudent Rollno. : ");
scanf("%s", student[x].rollno);
system("\npause");
goto exam;
}
admin = fopen("student.txt", "w");
fprintf(admin, "Name: %s \nRoll Number: %s\n\n", student.name, student.rollno);
fclose(admin);
如您所见,我正在尝试将每个名称和数字放入文本文件中,但我不断收到此错误
错误:在不是结构或联合的东西中请求成员“名称”| 错误:在不是结构或联合的情况下请求成员“rollno”
不管有没有结构,有没有办法把它放到一个文件中?