Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #define NULL 0
- struct linked_list
- {
- int number;
- struct linked_list *next;
- };
- typedef struct linked_list node;
- void create(node *myList);
- void print(node *myList);
- int main()
- {
- node *head;
- head = (node *) malloc(sizeof(node));
- create(head);
- printf("\n");
- print(head);
- printf("\n");
- return 0;
- }
- void create(node *myList)
- {
- printf("Input a number. (Enter -99999 at end)\n");
- scanf("%d", &myList->number);
- if(myList->number==-99999)
- myList->next = NULL;
- else
- {
- myList->next = (node *) malloc(sizeof(node));
- create(myList->next);
- }
- }
- void print(node *myList)
- {
- printf("%d ", myList->number);
- if(myList->next == NULL)
- return;
- print(myList->next);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement