Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.51 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. typedef struct szam{
  4. int data;
  5. struct szam * next;
  6.  
  7. }node;
  8. void addlist(int data, node*head){
  9. node* temp=head;
  10. while(temp->next!=NULL){
  11.     temp=temp->next;
  12. }
  13. temp->next=(node*) malloc(sizeof(node));
  14. temp=temp->next;
  15. temp->next=NULL;
  16. temp->data=data;
  17. }
  18.  
  19. void printnode(node *root){
  20. node*temp=root;
  21. while(temp){
  22.     printf("%d,",temp->data);
  23.     temp=temp->next;
  24. }
  25. }
  26. void main(){
  27.     node * head=NULL;
  28. addlist(10,head);
  29. addlist(20,head);
  30. printnode(head);
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement