字符串的插入
#include "stdio.h"#include "string.h"
char *insert(char *p1,char *p2,int k)
{ static char s[50],*t;
t=s;
for(;t<s+k;)
*t++=*p1++;
for(;t<s+k+strlen(p2);)
*t++=*p2++;
for(;t<s+strlen(p1)+strlen(p2);)
*t++=*p1++;
return(s);
}
void main()
{ char s1[20],s2[20],*s3;int m;
printf("s1:");
gets(s1);
printf("s2:");
gets(s2);
printf("enter m:");
scanf("%d",&m);
s3=insert(s1,s2,m);
printf("after insert:");
printf("%s",s3);
}
不知道哪里出错了,求指导