Advertisement
Guest User

Untitled

a guest
May 25th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. Teacher* Teacher_to_aar(int num)
  2. {
  3. FILE *Th;
  4. Teacher *tch;
  5. char chk[2]={'a'}, buffer[500],buffer2[500],buffer3[500],buffer4[500],Code[500];
  6. int Mhr,Ehr,tmp,i=0;
  7.  
  8. Th = fopen("Teacher.txt","r");
  9. if (Th == NULL) Get_Lost("Can't open Teacher.txtn");
  10. tch=(Teacher*)malloc(sizeof(Teacher)*num);
  11. if (tch == NULL)
  12. Get_Lost("Allocation failed");
  13. while(strcmp(chk,";") != 0)
  14. fscanf(Th,"%c",chk);
  15. for(i=0;i<num;i++)
  16. {
  17. fscanf(Th,"%s %s %s %s %s %d %d", Code, buffer,buffer2,buffer3,buffer4,&(tch[i].mHours),&(tch[i].eHours));
  18. tmp=strlen(buffer); // First name
  19. tch[i].fname = (char*)malloc(tmp);
  20. strcpy(tch[i].fname,buffer);
  21. tmp=strlen(buffer2); // Last name
  22. tch[i].lname = (char*)malloc(tmp);
  23. strcpy(tch[i].lname,buffer2);
  24. tmp=strlen(buffer3); // Title
  25. tch[i].title = (char*)malloc(tmp);
  26. strcpy(tch[i].title,buffer3);
  27. tmp=strlen(buffer4); // Prefrence
  28. tch[i].pref = (char*)malloc(tmp);
  29. strcpy(tch[i].pref,buffer4);
  30. tmp=strlen(Code); // Serial
  31. tch[i].serial = (char*)malloc(tmp);
  32. strcpy(tch[i].serial,Code);
  33. }
  34. }
  35.  
  36. fscanf(Th,"%c",chk);
  37.  
  38. 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.
  39.  
  40. Program received signal SIGABRT, Aborted.
  41. 0x00007ffff773a418 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
  42. 54 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement