need help in finding the error in my code
record typedef doesnt work for some reason..
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define TRUE 1
FILE *fstud;
FILE *fteacher;
record readscreen1(record stud);
record readscreen2(record teacher);
void writefile1(record stud);
void writefile2(record teacher);
typedef struct {
int id;
int psswrd;
} idpass;
typedef struct {
char ders;
int mark;
char ogrt_yorum;
} lesson_reprt;
typedef struct {
int month;
int day;
int year;
} date;
typedef struct {
char name[30];
char mahalle[30];
char city[20];
int tc_no;
idpass info;
date kayit;
} record;
int main()
{
record stud,teacher;
int n;
printf("Ogrenci [1]/Ogretmen[2]");
scanf("%d",&n);
switch (n)
{
case 1:
fstud=fopen("studrecords.dat","w+");
stud=readscreen1(stud);
writefile(stud);
fclose(fstud);
break;
case 2:
fteacher=fopen("teacherrecords.dat","w+");
teacher=readscreen2(teacher);
writefile(teacher);
fclose(fteacher);
break;
}
return 0;
}
record readscreen1(record stud)
{
printf("Tarih(gg/aa/yyyy: ");
scanf("%d/%d/%d",&stud.kayit.day,&stud.kayit.month,&stud.kayit.year);
printf("Isim: ");
scanf("%s",&stud.name);
printf("T.C. numarasi: ");
scanf("%d",&stud.tc_no);
printf("Sehir: ");
scanf("%s",&stud.city);
printf("Mahalle: ");
scanf("%s",&stud.mahalle);
printf("ID: ");
scanf("%d",&stud.info.id);
printf("Parolla: ");
scanf("%d",&stud.info.psswrd);
return (stud);
}
record readscreen2(record teacher)
{
printf("Tarih(gg/aa/yyyy: ");
scanf("%d/%d/%d",&teacher.kayit.day,&teacher.kayit.month,&teacher.kayit.year);
printf("Isim: ");
scanf("%s",&teacher.name);
printf("T.C. numarasi: ");
scanf("%d",&teacher.tc_no);
printf("Sehir: ");
scanf("%s",&teacher.city);
printf("Mahalle: ");
scanf("%s",&teacher.mahalle);
printf("ID: ");
scanf("%d",&teacher.info.id);
printf("Parolla: ");
scanf("%d",&teacher.info.psswrd);
return (teacher);
}
void writefile1(record stud)
{
fprintf(fstud,"%d/%d/%d\n",stud.kayit.day,stud.kayit.month,stud.kayit.year);
fprintf(fstud,"Isim: %s\n",stud.name);
fprintf(fstud,"T.C. No: %d\n",stud.tc_no);
fprintf(fstud,"Sehir: %s",stud.city);
fprintf(fstud,"Mahalle: %s",stud.mahalle);
fprintf(fstud,"ID: %d",stud.info.id);
fprintf(fstud,"Parolla: %d",stud.info.psswrd);
return;
}
void writefile2(record teacher)
{
fprintf(fteacher,"%d/%d/%d\n",teacher.kayit.day,teacher.kayit.month,teacher.kayit.year);
fprintf(fteacher,"Isim: %s\n",teacher.name);
fprintf(fteacher,"T.C. No: %d\n",teacher.tc_no);
fprintf(fteacher,"Sehir: %s",teacher.city);
fprintf(fteacher,"Mahalle: %s",teacher.mahalle);
fprintf(fteacher,"ID: %d",teacher.info.id);
fprintf(fteacher,"Parolla: %d",teacher.info.psswrd);
return;
}