标题:串替换有点错误,各位大神忙帮看看
取消只看楼主
寻找梦想1
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2013-5-1
结帖率:50%
已结贴  问题点数:5 回复次数:0 
串替换有点错误,各位大神忙帮看看
#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);
}  
搜索更多相关主题的帖子: pos include return 
2013-05-23 21:45



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-407871-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.140432 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved