gpt4 book ai didi

c - 为什么strlen()替换一个字符串?

转载 作者:行者123 更新时间:2023-11-30 21:42:15 25 4
gpt4 key购买 nike

我从互联网上得到了一个 pgm。但我对有关 strlen() 函数的代码感到困惑。 strlen() 是替换字符串吗?我是这个编码的初学者。帮助我。

下面的简单代码块:

while(NULL != fgets(Buffer, 4095, Input))
{
char *Stop = NULL;
char *Start = Buffer;

while(1)
{

Stop = strstr(Start, Find);
if(NULL == Stop)
{
fwrite(Start, 1, strlen(Start), Output);
break;
}
printf("\n@found at Line <%d>",line);
fwrite(Start, 1, Stop - Start, Output);
fwrite(Replace, 1, strlen(Replace), Output);
Start = Stop + strlen(Find);
}
line++;
}

为什么start = stop + strlen(find)替换字符串?

最佳答案

Is it strlen() replace a string ?

否,计算传递给它的字符串的长度。

why start = stop + strlen(find) replace a string ?

= 称为赋值运算符,它将右操作数的值赋给左操作数。 a = b; 表示将b 的值赋给a。希望它有意义。

我建议选择一本教科书,首先浏览基本概念运算符、字符串、函数和指针。然后你就会明白你的代码到底在做什么。

关于c - 为什么strlen()替换一个字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29294216/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com