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

int main() {
    char str[4] = "SAM";
    char val[80] = "SAMhelloSAMyelloSAM12345SAM54321helloSAMyelloMAShello";
    int len = strlen(val);
    char *index = strstr(val, str);

    if (index != NULL) {
        memmove(val, index + strlen(str), len - (index - val));
        printf("Output: %s\n", val);
    }

    return 0;
}

#if 0
/* A C program to demonstrate working of memmove */
#include <stdio.h> 
#include <string.h> 
  
int main() 
{ 
    char str1[] = "Geeks"; // Array of size 100 
    char str2[] = "Quiz"; // Array of size 5 
  
    puts("str1 before memmove "); 
    puts(str1); 
  
    /* Copies contents of str2 to sr1 */
    memmove(str1, str2, sizeof(str2)); 
  
    puts("\nstr1 after memmove "); 
    puts(str1); 
  
    return 0; 
}
#elseif

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: