What you have written clearly does not correspond to the task.
You need to enter 3 lines. The first, the one in which we are looking for and changing. The second is what we are looking for. Third - what we change.
Determine, also, the fourth, the one in which the result will be obtained.
Note that scanf ("% s", str) (str is correct , not & str (but you can & str [0]) (figure it out yourself why )) introduces a sequence of characters up to the first space, tab, or similar separator (more man). Is that exactly what you want? You can use fgets (str, sizeof (str), stdin) in your case to enter the full line.
To search for substrings in a string, it is convenient to use the function strstr (). To solve this problem, it must be called in a loop, each time shifting the beginning of the search in the source line. The cycle is completed, of course, when no entry is found.
With the details (copying), I hope, figure it out.
Please note that if it is necessary to replace the original line, it is not always possible if the result length exceeds the size of the original line.