Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- typedef struct node
- {
- int a;
- char ch;
- struct node *next;
- } node;
- node*head=NULL;
- void insert_nth(int n,int aN,char chN)
- {
- node *N=(node*)malloc(sizeof(node));
- N->a=aN;
- N->ch=chN;
- N->next=NULL;
- if(n==1)
- {
- N->next=head;
- head=N;
- return;
- }
- else
- {
- node*list=head;
- n=n-2;
- while(n!=0&&list->next!=NULL)
- {
- list=list->next;
- n--;
- }
- N->next=list->next;
- list->next=N;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment