Originally Posted by
Adak
See my edit I just made in my last post for an example for scanf()
when you tried doing that in your compiler, did it work fine? In my case, it didn't. This is what I did in the add_record() (is it correct?):
Code:
void add_record()
{
record stud;
char ch;
FILE *fp;
fp=fopen("std.dat","r+");
if(fp==NULL)
fp=fopen("std.dat","w");
clrscr();
gotoxy(35,1);printf("\n\nADD STUDENT RECORD\n\n");
do
{
printf("\n\nStudent number (must be 9 digits) = ");
scanf("%lld", &stud.snum);
printf("\nPassword = ");
scanf("%50s", &stud.password);
printf("\nLast name = ");
scanf("%31s", &stud.lname);
printf("\nFirst name = ");
scanf("%31s", &stud.fname);
printf("\nMiddle initial = ");
scanf("%3s", &stud.mi);
printf("\nBirthdate (MMDDYY) = ");
scanf("%7s", &stud.bday);
printf("\nCourse (ex.BSM) = ");
scanf("%6s", &stud.course);
fseek(fp,0,SEEK_END);
fwrite(&stud,sizeof(stud),1,fp);
printf("\n\nAdd another record? Y if yes\n\n");
ch=toupper(getche());
} while(ch=='Y');
fclose(fp);
getch();
}
May I see what how you did it? Maybe I didn't do it right.