#include
#include
#include
#define Acharlen 100
#define Bcharlen 20
char * mid(char * thechar,int start,int len)
{
char *my_char;
int i=0;
for(;start<start+len;start++,i++)
{
*(my_char+i)=thechar[start];
}
return my_char;
}
int insert(char *longchar,char * my_char,unsigned int start)
{
unsigned int i,j=strlen(longchar);
if(strlen(longchar)+strlen(my_char)>Acharlen)
return 0;
for(i=strlen(longchar);i>=start;i--)
*(longchar+i+strlen(my_char))=*(longchar+i);
for(i=0;i<=strlen(my_char);i++)
{
*(longchar+start+i)=*(my_char+i);
}
return 1;
}
void main()
{
char a[Acharlen];
char b[Bcharlen];
char c[Acharlen];
char *my_char;
unsigned int i,k;
printf("please intput many char\n");
gets(a);
printf("please input insert before many char\n");
gets(b);
printf("please input inser char\n");
gets(c);
for(i=0;i<=strlen(a)-strlen(b);i++)
{
my_char=mid(a,i,strlen(b));
if(strcmp(my_char,b))
break;
}
if(i>strlen(a)-strlen(b))
{
printf("you input error\n");
exit(0);
}
if(k=insert(a,c,i))
puts(a);
else
printf("error\n");
}