void Replace(char* str, const char* toFind, const char* toReplace)
{
int s = strlen(str);
int f = strlen(toFind);
int r = strlen(toReplace);
int counter = 0;
while (char* found = strstr(str, toFind))
{
counter++;
if (f < r)
{
int size = (s + 1) - (found + f - str);
if (size > 0)
{
memmove(found + r, found + f, (s + 1) - (found + f - str));
}
strncpy(found, toReplace, r);
}
else
{
strncpy(found, toReplace, r);
int size = (s + 1) - (found + f - str);
if (size > 0)
{
memmove(found + r, found + f, (s + 1) - (found + f - str));
}
}
}
str[s + counter*(r - f)] = '\0';
}