LinkedList/C/linkedList.c
//Function to insert at a position
Function to insert at a position
Function to insert at a position
void posins(int x, int pos){
	struct node *new, *ptr;
	new = (struct node*)malloc(sizeof(struct node));
	new -> data = x;
	if (head == NULL){
		head = new;
		head -> link = NULL;
		return;
	}
	ptr = head;
	int count = 0;
	while(count != pos && ptr -> link != NULL){
		ptr = ptr -> link;
		count++;
	}
	new -> link = ptr -> link;
	ptr -> link = new;
}
void posins ( int x , int pos ) { struct node * new , * ptr ; new = ( struct node * ) malloc ( sizeof ( struct node ) ) ; new -> data = x ; if ( head == NULL ) { head = new ; head -> link = NULL ; return ; } ptr = head ; int count = 0 ; while ( count != pos && ptr -> link != NULL ) { ptr = ptr -> link ; count ++ ; } new -> link = ptr -> link ; ptr -> link = new ; }
Function to insert at a position
Function to insert at a position