c语言如何删除一个字符串,c语言编程怎么删掉一个字符串中的子字符串

d5a06755868d23850470d0f5c6bc0e89.png

int Replace_string(char line[],char str1[],char str2[])

{

char *source = line;

char *old = str1;

char *New = str2;

char *destination = source;

char temp = [256];

int i,j,k,flag = 0;

int location = -1;

int old_lenght = strlen(old);

for (i=0; source[i]; i++)

{

for (j=i,k=0; source[j] = old[k]; k++,j++)

{

location++;

flag = 1;

}

}

if(falg == 1)

{

if (location != -1)

{

for (j=0; j

{

temp[j] = source[j];

}

for (i=0; New[i]; i++,j++)

{

temp[j] = New[i];

}

for (k=location+old_lenght; source[k]; k++,j++)

{

temp[j] = source[k];

}

source[j] = '\0';

for (i=0; source[i] = temp[i]; i++);

}

}

else

return 0;

return flag;

}

◆◆

评论读取中....

请登录后再发表评论!

◆◆

修改失败,请稍后尝试

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值