C: strings and pointers. changing sub-strings within a string in a specific pattern
===

I'm having a hard time understanding how should I do the following:

I have string such that it contains words and two StringNodes- struct as following:

    typedef struct_StringNode{
    char *str;
    struct _StringNode* next;
    }StringNode;

   I need to write a function which receives two lists as above, of the same size, and I need to replace every appearance of a word from the original string I received with the matching string of the second list.

Example:

text: stack overflow siteoverflow oveflow stack

pattern: stack overflow site

replacement:Hello guys here

Result:Hello guys hereguys guys Hello

For each word: I'm trying to use *strstr* so I'll get a pointer to an occurrence of the word in a copy of the string and then to change thee word, and to promote the pointer of the copy of the text string.

    char* replace (char* text, StringNode* pattern, StringNode* replacement){
    char* currentWord, toreplace;
    Allocat some space for them;
    while(pattern!=NULL){
    currrentWord= pattern->str;
    toreplace=replacement->str;
    copy=text;
    while((place=(strstr(copy,currentWord))! NULL){
    place=toreplace; //Have I changed anything at the original string//
    copy+=strlen(place); Do I really promote copy as I should?
    }
    pattern=pattern->next;
    toreplace=toreplace->next
    ....
    ....


     



 
