Sheokand and String(SHKSTR) TLE for 3rd task

I think my code is getting into a infinity loop in task 3, but i am unable to find the problem.
Here is my code.

The while loop inside to search function is running infinitely.
because in some case in task 3 the condition ((head->next[i]!=NULL)&& (head->next[i]->id)<idS) never becomes true. please help me.