Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- typedef struct IntNode
- {
- struct IntNode *next;
- int data;
- } IntNode;
- IntNode *head;
- IntNode * insertLast(IntNode*head, int c)
- {
- IntNode *tmp, *cursor;
- if (head==NULL)
- {
- tmp= malloc(sizeof(IntNode));
- tmp->data = c;
- tmp->next = head;
- return tmp;
- }
- else
- {
- cursor=head;
- while (cursor->next != NULL)
- {
- cursor =cursor->next;
- }
- tmp= malloc(sizeof(IntNode));
- tmp->data = c;
- tmp->next = NULL;
- cursor->next=tmp;
- return head;
- }
- }
- void printList(IntNode *head)
- {
- IntNode *zeiger;
- zeiger=head;
- printf("Beginn der Liste ( ");
- while (zeiger =!NULL)
- {
- printf("%d", zeiger-> data);
- printf(" ");
- zeiger=zeiger->next;
- }
- printf(")"); // Ende der Liste
- }
- int main()
- {
- IntNode *head=NULL;
- IntNode *L1;
- L1= insertLast(L1,3);
- printList(L1);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement