Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. void add(lista **poz, kontakt nowa)
  2. {
  3. kontakt contact1;
  4. lista *kontener = (lista*)calloc(1, sizeof(lista));
  5. if (kontener == NULL)
  6. return;
  7. if ((*poz) == NULL)
  8. {
  9. (*poz) = (lista*)malloc(sizeof(lista));
  10. *poz = (*poz)->next;
  11. }
  12. else
  13. {
  14. ((*poz)->next) = (lista*)malloc(sizeof(lista));
  15. if ((*poz)->next == NULL)
  16. return;
  17. }
  18.  
  19. kontener->dane = nowa;
  20. kontener->next = *poz;
  21. if (*poz != NULL)
  22. {
  23. if ((*poz)->prev != NULL) (*poz)->prev->dane = nowa;
  24. kontener->prev = (*poz)->prev;
  25. (*poz)->prev = kontener;
  26. }
  27. *poz = kontener;
  28.  
  29. printf("Podaj Imie: ");
  30. scanf("%s", contact1.imie);
  31. printf("Podaj Nazwisko: ");
  32. scanf("%s", contact1.nazwisko);
  33. printf("Podaj numer: ");
  34. scanf("%s", contact1.numer);
  35. printf("Podaj grupe: ");
  36. scanf("%s", contact1.grupa);
  37. printf("\n");
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement