Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- struct list_item{
- int value;
- struct list_item *next;
- };
- void append(struct list_item *first, int x){ //puts x at the end of the list
- struct list_item *new_ptr = (struct list_item*)malloc(sizeof(new_ptr));
- struct list_item new_item;
- new_ptr = &new_item;
- new_item.value = x;
- new_item.next = NULL;
- while(first->next != NULL){
- //first = *first.next;
- first = first->next;
- }
- printf("append ger first %d", first->next);
- first->next = new_ptr;
- };
- void prepend(struct list_item *first, int x);
- void print(struct list_item *first);
- void input_sorted(struct list_item *first, int x);
- void clear(struct list_item *first, int x);
- int main(int argc, char ** argv) {
- struct list_item root;
- struct list_item *ptr = &root;
- root.value = -1;
- root.next = NULL;
- append(ptr,3);
- ptr = &root;
- append(ptr,4);
- struct list_item last = *root.next;
- struct list_item nextie = *last.next;
- //printf("list_item = %d \n",last.value);
- //printf("list_item = %d \n",nextie.value);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement