C语言将字符串1接到2,用c语言实现把字符串1中的所有字符串2改为字符串3

满意答案

dcebd7a0de6265b6ccae5ead692f1eab.png

bzkk36

2016.07.28

dcebd7a0de6265b6ccae5ead692f1eab.png

采纳率:58%    等级:12

已帮助:7250人

#include

#include

#include

int main()

{

char str1[1000] = { 0 }, str2[100] = { 0 }, str3[100] = { 0 };//字符串1串长最大数值为999字节,字符串2、3串长最大数值为99

scanf("%s%s%s", str1,str2,str3);

char temp[100] = { 0 }, temp1[1000] = { 0 }, temp2[1000] = { 0 };

int i = 0, j = 0;

for (i = 0; i 

{

int len = i + strlen(str2);

for (j = i; j 

{

temp[j - i] = str1[j];

}

if (strcmp(temp, str2) == 0)

{

for (j = 0; j 

temp1[j] = str1[j];

for (j = len; j 

temp2[j - len] = str1[j];

strcpy(temp, str3);

strcpy(str1, temp1);

strcat(str1, temp);

strcat(str1, temp2);

}

}

printf("%s", str1);

system("pause");

return 0;

}

01分享举报

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值