Look at your code: you have a loop limited to the length of the string, but you access characters beyond that limit:
while (str[i] != '\0')
{
while (str[i + j] == to_find[j] && str[i + j] != '\0')
Since you increment
j
without checking if
to_find
is exhausted, you can go well outside the loop bounds.
Use the debugger to follow exactly what your code is doing while it is running, and you'll see where your problem happens and what your variables contain.