#include<stdio.h>
#include<stdlib.h>
int main()
{
char s[]="I have an apple.Do you like apple?";
char s1[]="apple";
char s2[]="orange";
int i,j,k,h,p,c;
for(p=0;s[p]!='\0';)
p++;
for(i=0;s[i]!='\0';i++)
for(j=i,k=0;s1[k]==s[j];k++,j++)
if(s1[k+1]=='\0')
{
for(i=j-k,h=0;s[i]!='\0'&&s2[h]!='\0';)
{
if(h>k)
{
for(c=p-1;c>=i;c--)
s[c+1]=s[c];
}
s[i++]=s2[h++];
}
break;
}
printf("%s\n",s);
system("pause");
return 0;
}
/*#include
#include
char s1[50];
char s2[]={'a','p','p','l','e'};
char s3[]={'o','r','a','n','g','e'};
char target [100];
int i=0,j,count=0;
int main()
{
gets(s1);
while(s1[i]!='\0')
{
if((s1[i]==s2[0])&&(s1[i+1]==s2[1])&&(s1[i+2]==s2[2])&&(s1[i+3]==s2[3])&&(s1[i+4]==s2[4]))
{
for(j=0;j<strlen(s3);j++)
{
target[count]=s3[j];
count++;
}
i=i+5;
}
else
{
target[count]=s1[i];
count++;
i++;
}
}
puts(target);
return 0;
}