串替换有点错误,各位大神忙帮看看
#include "stdio.h"#include "stdlib.h"
#define MAXSTRLEN 255
typedef unsigned char SString[MAXSTRLEN+1];
int Index(SString s1,SStrings2,int pos)
{
}
Status StrDelete(SString s,int pos,int len)
{
int i;
if(pos<1||pos>s[0]-len+1||len<0)
return 0;
for(i=pos+len;i<=s[0];i++)
s[i-len]=s[i];
s[0]=len;
return 1;
}
void Replace(SString s1,SString s2,SString s3)
{
int i;
char t;
do
{
i=Index(s1,s2,i);
if(i)
{
StrDelete(s1,i,s2[0]);
t=(StrInsert(s1,i,s3));
if(!t)
return 0;
else
i+=s3[0];
}whlie(i);
}
main()
{int i;char t;
SString s1,s2,s3;
printf("请输入串s1:");
scanf("%s",s1);
printf("请输入串s2:");
scanf("%s",s2);
t=Replace(s2,i,s3);
printf("the replaced s1:%s",s1);
}