I'm using first time structures in my program.
Problem: I want to make a record of student (maximum 10 student). so i use arrays structures. After compile and running the program and after entering the data of stuct members, i m getting a error and the program is terminated by windows explorer. somebody help me please.
Code:
#include<conio.h>
#include<stdio.h>
struct database{
char name[20][10];
char clas[5][10];
int roll_no[10];
int age[10];
int marks[10];
char adress[50][10];
};
main()
{
int i,totSt;
struct database student;
printf("\tStudents's Record\n");
printf("NOTE: In this program, you can save data for 10 student maximum.\n");
printf("Number of students:");
scanf("%d",&totSt);
for (i=1; i<=totSt; i++)
{
printf("Enter Roll Number:");
scanf("%d",&student.roll_no[i]);
printf("Enter Name:");
scanf("%s",&student.name[i]);
printf("Enter Class:");
scanf("%s",&student.clas[i]);
printf("Enter Age:");
scanf("%d",&student.age[i]);
printf("Enter Marks:");
scanf("%d",&student.marks[i]);
printf("Enter Address:");
scanf("%s",&student.adress[i]);
}
printf("\nRoll No. | NAME | Class | Age | Marks | Address");
for (i=1; i<=totSt; i++)
{
printf("\n %d. | %s | %s | %d | %d | %s ",student.roll_no[i],student.name[i],student.clas[i],student.marks[i],student.adress[i]);
printf("-------------------------------------------------------------------");
}
getch();
}