Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. struct liste{
  5. int wert;
  6. struct liste *next
  7. };
  8.  
  9. struct liste* NewListElem(int a){
  10. struct liste *test;
  11. if(test = (struct liste*) malloc(sizeof(struct liste))== 0){
  12. //printf("Fehler");
  13. exit(-1);
  14. }
  15. else {
  16. printf("Kein Fehler\n");
  17. }
  18. test->wert = a;
  19. test->next = NULL;
  20. //list -> wert = a;
  21. return test;
  22. }
  23. void AppendListElem(struct liste* list, int a){ //wie insert in Java
  24. struct liste *Next = list -> next;
  25. list -> next = NewListElem(a);
  26. list -> next -> next = Next;
  27. }
  28.  
  29. int main(){
  30.  
  31. struct liste *list = NewListElem(-1);
  32. int i = 0;
  33. i = (*list).wert;
  34. printf("%i", i);
  35.  
  36. AppendListElem(list, 3);
  37. AppendListElem(list, 4);
  38.  
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement