我有一个C语言的基本问题?我在编译代码的时候遇到了一个奇怪的警告,说s1和s2“没有使用计算的值”,但我最终的结果是正确的。为什么?
static const char *CutStringNchar(const char *s1, const char *s2)
{
if ((s1 == NULL) || (s2 == NULL))
{
return NULL;
}
char ch1 = *s1;
char ch2 = *s2;
while (1)
{
if (ch1 == ch2)
{
*s1++;
*s2++;
ch1 = *s1;
ch2 = *s2;
//printf("ch1 = %c\n", ch1);
if (ch2 != '\0')
{
continue;
}
else
{
return s1;
}
}
else
{
return NULL;
}
}
}
int main(void)
{
printf("ret = %s\n", CutStringNchar("test/aa", "test/a"));
const …Run Code Online (Sandbox Code Playgroud) c ×1