Find first word.
Save the number which shows where the first lettter is.
Save the length of the word.
For example first_letter1 = 5 (the 5th letter of the string), len1=10 (it has 10 letters)
Find second word. Do as above.
Calculate also the length between the two words (since you read sequentially from a string it should be easy)
You have all the information you need.
Malloc an array as big as the length of the first word + lenght of second word + length of the space
in between the letters.
Copy in that array first the second word (which would be my_string[first_letter2]).
Then copy everything in between.
Then copy the first word.
Then copy this array in the beggining of the first array.
You will have what you want