#include <stdio.h>
#include <string.h>

typedef struct replace
{
	const char *from, *to;
} replace;

char* strreplace(char *str, const replace *replaces)
{
	char *s = str;
	while (*s)
	{
		const replace *r = replaces;
		while (r->from)
		{
			int len_from = strlen(r->from);
			if (strncmp(s, r->from, len_from) == 0)
			{
				int len_to = strlen(r->to);
			    memmove(s+len_to, s+len_from, strlen(s+len_from)+1);
			    memcpy(s, r->to, len_to);
			    s += len_to - 1;
				break;
			}
			
			++r;
		}
		
		++s;
	}
	
	return str;
}

int main(void) {
    char string3[200] = "Hallo, diese Nachricht wird ersetzt. Dieser Quelltext gehoert zu den Systemen.";
    replace replaces[] =
    {
    	{ "en", "x"},
    	{ "x", "en"},
    	{ "er", "q"},
    	{ "q", "er"},
    	{ "y", "ch"},
    	{ "ch", "y"},
    	{ "a", "o"},
    	{ "o", "a"},
    	{ NULL, NULL }
    };

    printf("Vorher: %s\n", string3);

    printf("Nachher: %s\n", strreplace(string3, replaces));

	return 0;
}


