Linked_List_Example.c
/*
This function searches the list by iterating over
every node. First it checks the head pointer,
wheter it is NULL or not. Then iterates through
the list. Also it checks if the current node is
last one or not. Incase of it can not find returns -1
*/
This function searches the list by iterating over
every node. First it checks the head pointer,
wheter it is NULL or not. Then iterates through
the list. Also it checks if the current node is
last one or not. Incase of it can not find returns -1
This function searches the list by iterating over every node . First it checks the head pointer wheter it is NULL or not . Then iterates through the list . Also it checks if the current node is last one or not . Incase of it can not find returns - 1
int list_search(node_t * head, int search)
{
	int index = 0;
	node_t * current = head;
	if (head == NULL)
		return -1;
	do
	{
		if (search == current->val)
		{
			return index;
		}
		current = current->next;
		index++;
	} while (current->next != NULL);
	return -1;
}
int list_search ( node_t * head , int search ) { int index = 0 ; node_t * current = head ; if ( head == NULL ) return -1 ; do { if ( search == current -> val ) { return index ; } current = current -> next ; index ++ ; } while ( current -> next != NULL ) ; return -1 ; }
This function searches the list by iterating over
every node.
This function searches the list by iterating over every node .