I'm new with linked lists and I have bug that I can not find. I have single linked list filled with numbers which I send as argument to the function search_tnode. If function found number that I'm searching for it returns and in main I can use new list starting with that number. If function does not find the number it returns and in main I have empty list while I want to have original list that I sent as argument. How can I achieve this?
main:
Code:
my_list = search_tnode(my_list,key);
function:
Code:
struct t_node * search_tnode(struct t_node *start_time, unsigned long num){
struct t_node *p;
p = start_time;
while(p != NULL){
if(p->key == num){
return p;
}
p = p->next;
}
printf("Number not found %ld \n",num);
return start_time; }