Advertisement
Guest User

Untitled

a guest
May 21st, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. void Marks(FILE* S)
  2. {
  3. char ch[1];
  4. ch[0] = fgetc(S);
  5. printf("\n ch! = %c\n ", ch);
  6. Node* tmp = (Node*)malloc(sizeof(Node*));
  7. int* a = NULL;
  8. int* b;
  9. int i = 0;
  10. int k = 0;
  11. if (!feof(S))
  12. {
  13. do
  14. {
  15. if (ch[0] == '/')
  16. {
  17. continue;
  18. }
  19. b = (int*)realloc(a, (i + 1) * sizeof(int));
  20. a = b;
  21. *a = atoi(ch);
  22. printf("%d", *a);
  23. i++;
  24. k++;
  25. } while (((ch[0] = fgetc(S)) != '#') && (!feof(S)));
  26. tmp->marks = a;
  27. tmp->k = k;
  28. //printf("Vivod k = %d", k);
  29.  
  30. }
  31. }
  32. //чтение файла
  33. void readfile(List* list, FILE *S)
  34. {
  35. fopen_s(&S, "input.txt", "rt");
  36. Node* tmp = (Node*)malloc(sizeof(Node));
  37. char * tmpc;
  38. tmp->data = (char*)malloc(1000);
  39.  
  40. while (!feof(S))
  41. {
  42. //фамилия
  43. tmpc = tmp->data;
  44. int ch;
  45. while(((ch = fgetc(S)) != ' ') && (!feof(S)))
  46. {
  47. *(tmpc) = ch;
  48. tmpc++;
  49. printf("end");
  50. }
  51. *(tmpc) = '\0';
  52. // оценки
  53. Marks(S);
  54. tmp->next = NULL;
  55. if (list->head == NULL)
  56. {
  57. list->head = tmp;
  58. //printf("UHJH");
  59. }
  60. else
  61. {
  62. Node* last = getLastNodeIfNotEmpty(list);
  63. last->next = tmp;
  64. //printf("UHJHlsdfgs");
  65. }
  66. }
  67. fclose(S);
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement