/* 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 <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
   FILE *fp;
   int n;
   char *p;
   char buf[10000];
   fp = fopen("z.txt", "r+b");
   fseek(fp,0,SEEK_SET);
   n = fread(buf,1,sizeof(buf),fp);
   p = strstr(buf,"1234"); 
   if(p != NULL)
   {
      memcpy(p,"4321",strlen("4321"));
      fseek(fp,0,SEEK_SET);
      fwrite(buf,1,n,fp);
   }
   fclose(fp);
   return 0;
}
