Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- typedef struct listaelem
- {
- int data;
- struct listaelem* next;
- }listaelem;
- listaelem* push_front(listaelem* head, int d)
- {
- listaelem* p = (listaelem*)malloc(sizeof(listaelem));
- p->data = d;
- p->next = head;
- head = p;
- return head;
- }
- int main()
- {
- listaelem* head = NULL;
- head = push_front(head, 2);
- head = push_front(head, 5);
- listaelem* p = head;
- while (p != NULL)
- {
- printf("%d ", p->data);
- p = p->next;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement