/* Collection of code snippets by Arne Vajhøj */
/* (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) */
#include <stdlib.h>
#include <string.h>

void replace(char *s,char *s1,char *s2)
{
   int i,j;
   char *tmp;
   tmp = malloc(strlen(s)+1);
   strcpy(tmp,s);
   i = 0;
   j = 0;
   while(i<strlen(tmp)) {
      if(strncmp(tmp+i,s1,strlen(s1))==0) {
         strcpy(s+j,s2);
         i=i+strlen(s1);
         j=j+strlen(s2);
      } else {
         s[j]=tmp[i];
         i++;
         j++;
      }
   }
   s[j] = '\0';
   return;
}
