program to remove str2 from str1
#include<stdio.h> #include<string.h> char* mystrcmp(char*,char*); main() { char str1[50],str2[50],ch; printf("enter string1\n"); scanf("%[^\n]s",str1); printf("enter a string2\n"); scanf(" %s",str2); mystrcmp(str1,str2); printf("str1=%s str2=%s\n",str1,str2); } char* mystrcmp(char* s1,char* s2) { char *p; int count=0; p=s1; while(p=strstr(p,s2)) { count++; strcpy(p,p+(strlen(s2))); } printf("%d\n",count); return(s1); }OutPut:
madan@madan-Lenovo-G570:~/madan$ cc array13.c madan@madan-Lenovo-G570:~/madan$ ./a.out enter string1 welcome enter a string2 com 1 str1=wele str2=com