Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3.  
  4. struct a
  5. {
  6. char a;
  7. int b;
  8.  
  9. struct a *p;
  10. };
  11. struct a *ptr,*head,*first,*last2;
  12. int main()
  13. {
  14.  
  15. int i;
  16. ptr=(struct a*)malloc(sizeof(struct a));
  17. char k='a';
  18. int l=1;
  19. head=ptr;
  20. for(i=1; i<=26; i++)
  21. {
  22. ptr->a=k++;
  23. ptr->b=l++;
  24.  
  25.  
  26. if(i!=27)
  27. {
  28.  
  29. ptr->p=(struct a*)malloc(sizeof(struct a));
  30. ptr=ptr->p;
  31. }
  32. }
  33. ptr->p=NULL;
  34.  
  35.  
  36.  
  37. first=(struct a*)malloc(sizeof(struct a));
  38.  
  39. ptr=head;
  40. head=first;
  41.  
  42. first->a='A';
  43. first->b=96;
  44. first->p=ptr;
  45.  
  46.  
  47.  
  48. ptr=head;
  49. while(ptr->p!=NULL)
  50. {
  51.  
  52.  
  53. printf("%c ",ptr->a);
  54. printf("%d\n",ptr->b);
  55. ptr=ptr->p;
  56.  
  57. if(ptr->p==NULL)
  58. {
  59. last2=(struct a*)malloc(sizeof(struct a));
  60.  
  61. last2->a='H';
  62. last2->b=102;
  63. ptr->p=last2;
  64. ptr=ptr->p;
  65.  
  66. printf("%c ",ptr->a);
  67. printf("%d\n",ptr->b);
  68.  
  69. break;
  70. }
  71.  
  72. }
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement