Advertisement
afrinahoque

LinkedListFunction1

Sep 24th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.52 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. typedef struct node
  4. {
  5.     int a;
  6.     char ch;
  7.     struct node *next;
  8. }node;
  9.  
  10. node *head;
  11.  
  12. void insert_at_first(int aN, char chN)
  13. {
  14.     node *N=(node*)malloc(sizeof(node));
  15.     N->a=aN;
  16.     N->ch=chN;
  17.     N->next=NULL;
  18.  
  19.     if(head==NULL)
  20.     {
  21.         head=N;
  22.         return;
  23.     }
  24.     N->next=head;
  25.  
  26.     head=N;
  27. }
  28.  
  29. int main()
  30. {
  31.     head=NULL;
  32.     insert_at_first(5,'x');
  33.     insert_at_first(4, 'y');
  34.     insert_at_first(3, 'z');
  35.     insert_at_first(9, 'i');
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement