LinkedList/C/linkedList.c
//Function to insert before a specific data node
Function to insert before a specific data node
Function to insert before a specific data node
void datains(int x, int data){
	struct node *new, *ptr, *ptr1;
	new = (struct node*)malloc(sizeof(struct node));
	new -> data = x;
	if (head == NULL){
		head = new;
		head -> link = NULL;
		return;
	}
	ptr = head;
	while(ptr -> data != data && ptr -> link != NULL){
		ptr1 = ptr;
		ptr = ptr -> link;
	}
	new -> link = ptr;
	ptr1 -> link = new;
}
void datains ( int x , int data ) { struct node * new , * ptr , * ptr1 ; new = ( struct node * ) malloc ( sizeof ( struct node ) ) ; new -> data = x ; if ( head == NULL ) { head = new ; head -> link = NULL ; return ; } ptr = head ; while ( ptr -> data != data && ptr -> link != NULL ) { ptr1 = ptr ; ptr = ptr -> link ; } new -> link = ptr ; ptr1 -> link = new ; }
Function to insert before a specific data node
Function to insert before a specific data node