Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- struct LinkedList
- {
- int data;
- struct LinkedList *next;
- };
- void addValue(struct LinkedList *, int val);
- void addItem(struct LinkedList *,struct LinkedList *);
- int main(){
- struct LinkedList start;
- start.data = 1;
- start.next = NULL;
- printf("%d",start.data);
- for(int i=0;i<10;i++){
- addValue(&start, i*i);
- addItem(&start,&newItem);
- }
- return 0;
- }
- void addItem(struct LinkedList *list,struct LinkedList *item){
- while(list->next != NULL)
- list = list->next;
- list->next = item;
- }
- void addValue(struct LinkedList *list, int val){
- struct LinkedList newItem;
- newItem.data = val;
- newItem.next = NULL;
- addItem(list, &newItem);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement