方法一
void strnins(char *s, char *t, int i)
{
if (i<0 && i>strlen(s)){
printf("Position is out of bounds. \n");
}
if (!strlen(s))
strcpy(s,t);
else if (strlen(s))
{
strcat(t, (s + i));
strcpy((s+i),t);
}
}
方法二
void strnins(char *s, char *t, int i)
{
char string[MAXSIZE], *temp = string;
if (i<0 && i>strlen(s)){
printf("Position is out of bounds. \n");
}
if (!strlen(s))
strcpy(s, t);
else if (strlen(s))
{
strncpy(temp,s,i);
strcat(temp,t);
strcat(temp,(s+i));
strcpy(s,temp);
}
}