Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Teacher* Teacher_to_aar(int num)
- {
- FILE *Th;
- Teacher *tch;
- char chk[2]={'a'}, buffer[500],buffer2[500],buffer3[500],buffer4[500],Code[500];
- int Mhr,Ehr,tmp,i=0;
- Th = fopen("Teacher.txt","r");
- if (Th == NULL) Get_Lost("Can't open Teacher.txtn");
- tch=(Teacher*)malloc(sizeof(Teacher)*num);
- if (tch == NULL)
- Get_Lost("Allocation failed");
- while(strcmp(chk,";") != 0)
- fscanf(Th,"%c",chk);
- for(i=0;i<num;i++)
- {
- fscanf(Th,"%s %s %s %s %s %d %d", Code, buffer,buffer2,buffer3,buffer4,&(tch[i].mHours),&(tch[i].eHours));
- tmp=strlen(buffer); // First name
- tch[i].fname = (char*)malloc(tmp);
- strcpy(tch[i].fname,buffer);
- tmp=strlen(buffer2); // Last name
- tch[i].lname = (char*)malloc(tmp);
- strcpy(tch[i].lname,buffer2);
- tmp=strlen(buffer3); // Title
- tch[i].title = (char*)malloc(tmp);
- strcpy(tch[i].title,buffer3);
- tmp=strlen(buffer4); // Prefrence
- tch[i].pref = (char*)malloc(tmp);
- strcpy(tch[i].pref,buffer4);
- tmp=strlen(Code); // Serial
- tch[i].serial = (char*)malloc(tmp);
- strcpy(tch[i].serial,Code);
- }
- }
- fscanf(Th,"%c",chk);
- Main: malloc.c:2395: sysmalloc: Assertion `(old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)' failed.
- Program received signal SIGABRT, Aborted.
- 0x00007ffff773a418 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
- 54 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement