大家帮帮看一下这个串的函数怎么调
/* Note:Your choice is C IDE */#include "stdio.h"
#include<malloc.h>
#define MAX 256
#define LEN sizeof(char)*MAX
typedef struct
{
char *ch;
int len;
int strsize;
}strings;
void initstring(strings *s)
{
s->ch=(char *)malloc(LEN);
s->len=0;
s->strsize=MAX;
}
void in_string(strings *s)
{
int i=0;
char ch;
while( (ch=getchar())!='\n'&&i<s->strsize )
s->ch[i++]=ch;
s->len=i;
}
strings *substr(strings *s,int i,int j,strings *t)
{ //在字符串s中,把从第i个字符开始的连续j个字符存入字符串t中
int k;
if(i<=0||i>=s->len||j<0||j>s->len-i+1)return 0;
if(t->len<j)
{
t->ch=(char *)realloc(t->ch,j*sizeof(char));
t->len=j;
}
for(k=0;k<j;k++)
t->ch[k]=s->ch[i-1+k];
t->len=j;
return t;
}
strings *insert(strings *s,int i,strings *t)
{ //在字符串s的第i个字符之前插入字符串t
int j;
if(i<=0||i>s->len+1)return 0;
if(s->strsize<s->len+t->len)
{
s->ch=(char *)realloc(s->ch,(s->len+t->len)*sizeof(char));
s->len=s->len+t->len;
}
for(j=s->len-1;j>=i-1;j--)
s->ch[j+t->len]=s->ch[j];
for(j=0;j<t->len;j++)
s->ch[i-1+j]=t->ch[j];
s->len+=t->len;
return s;
}
strings *del(strings *s,int i,int j)
{ //在字符串中,删除从第i个字符开始的连续j个字符
int k;
if(i<=0||i>=s->len||j<0||j>s->len-i+1)return 0;
for(k=i+j-1;k<s->len;k++)
s->ch[k-j]=s->ch[k];
s->len-=j;
return s;
}
void list(strings *s)
{
int i;
for(i=0;i<s->len;i++)
printf("%c",s->ch[i]);
printf("\n");
}
void main()
{
strings *s,*t,*r,a,b,c;
int i,j;s=&a;t=&b;r=&c;
initstring(s);initstring(t);
printf("请输入第一个字符串:");in_string(s);
printf("请输入要取出的字符串位置和个数:");
scanf("%d%d",&i,&j);
s=substr(s,i,j,t);
printf("删除后的字符串为:");list(s);
in_string(r);initstring(r);in_string(r);
printf("请输入要插入的位置:");scanf("%d",&i);
s=insert(s,i,r);list(s);
}
这个调用插入函数不知道怎样改才能重新传给它两个新的字符串,还有最后那个删除函数也不打懂调用。请大家帮帮写一下。