ok perhaps you all could help me with this illegal operation


when i attempt to use the code and try replacing all "\n" with "\r\n" i get an illegal operation..

Code:
char* replacestr(const char* str,const char* crt,const char* rep,char*trg){
    char* temp=trg;
    for(;*str; ){
        for(const char*i=crt,*j=str;*j&&*i&&*i==*j;j++,i++);
        if (!*i){
            for(i=rep;*i;*trg++=*i++)str++;
            str=j;
        }else 
            *trg++=*str++;
    }
    *trg=0;
    return temp;

};
i am calling the code as follows

Code:
replacestr(pszFileText, "\r", "\r\n", pszFileText);
pszfiletext is defined as LPSTR pszFileText and contains the data from a previously loaded txt file..