Advertisement
Guest User

Untitled

a guest
May 27th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include <stdio.h>
  2. #include<stdlib.h>
  3. #define flush while((getchar()) != '\n')
  4.  
  5. struct sinhvien
  6. {
  7. char name[100];
  8. int nums;
  9. float p[3];
  10.  
  11. };
  12. int count()
  13. {
  14. FILE *quanly =fopen()
  15.  
  16. int c = 0; int temp = fgetc(quanly);
  17. while (temp != EOF)
  18. {
  19. c++;
  20. fseek(quanly, sizeof(struct sinhvien)*c, SEEK_SET);
  21. }
  22. fclose(quanly);
  23. return c;
  24.  
  25. }
  26. void add(int n)
  27. {
  28. int c = count();
  29. for (int i = 1; i <= n; i++)
  30. {
  31. struct sinhvien sv;
  32. sv.nums = i + c;
  33. flush;
  34. gets(sv.name);
  35. for(int i=0;i<n;i++)
  36. {
  37. scanf("%f", &sv.p[i]);
  38. fseek(quanly, 0, SEEK_END);
  39. fwrite(&sv, sizeof(sv), 1, quanly);
  40. }
  41.  
  42. }
  43.  
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement