Advertisement
Marko35S

Untitled

Jun 2nd, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. node* init(FILE *input,node *head) {
  2.  
  3. node *help = head,*temp=NULL;
  4.  
  5. char c = 'a';
  6.  
  7. while (c != EOF) {
  8. if (head == NULL) {
  9.  
  10. head = malloc(sizeof(node));
  11.  
  12. help = head;
  13.  
  14. fscanf(input, "%s", &head->name);
  15. fscanf(input, "%d", &head->prisutnost);
  16. fscanf(input, "%d", &head->uticaj);
  17. fscanf(input, "%d", &head->otvorenost);
  18. fscanf(input, "%d", &head->izuzetnost);
  19.  
  20.  
  21. head->neu = countNew(head->prisutnost, head->uticaj, head->otvorenost, head->izuzetnost);
  22.  
  23. head->old = countOld(head->prisutnost, head->uticaj, head->otvorenost, head->izuzetnost);
  24.  
  25. head->next = NULL;
  26. }
  27. else {
  28.  
  29.  
  30. temp = malloc(sizeof(node));
  31.  
  32. fscanf(input, "%s%d%d%d%d", &temp->name, &temp->prisutnost, &temp->uticaj, &temp->otvorenost, &temp->izuzetnost);
  33.  
  34. temp->neu = countNew(temp->prisutnost, temp->uticaj, temp->otvorenost, temp->izuzetnost);
  35.  
  36. temp->old = countOld(temp->prisutnost, temp->uticaj, temp->otvorenost, temp->izuzetnost);
  37.  
  38. temp->next = NULL;
  39.  
  40. help->next = temp;
  41.  
  42. help = temp;
  43.  
  44. }
  45.  
  46. c = fgetc(input);
  47. }
  48. return head;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement