字符串插入
程序代码:#include<stdio.h>
char *insert(char *s,char *p,int n)
{
char *str,strcp[50];
int i;
str=strcp;
for(i=0 ;*s != '\0' ;i++)
{
if(i == n-1)
for( ;*p != '\0'; )
{
str[i]=*p;
p++;
i++;
}
str[i]=*s;
s++;
}
str[i+1]='\0';
return str;
}
void main()
{
int n;
char *a,*b;
a="we are friends";
b="good";
printf("please input the position\n");
scanf("%d",&n);
a=insert(a,b,n);
printf("%s\n",a);
getch();
}大家找找看问题在哪 这是一个字符串插入函数 得不到想要的结果










