删除C++ char*有点地址

Inf*_*ner 1 c++

由于我更改了项目设置,因此下面的布尔值返回false,因为在调试器中,char*参数的值包含指针地址.我怎么删除这个?

我创建了这个简单的例子来说明(我必须保留char*数据类型),我不能进行模式匹配来删除指针地址.

void Test(char* thisValue) 
{
if (thisValue == "PassingTest")
{
bo = true;
}
else
{
bo = false;
}
}
Run Code Online (Sandbox Code Playgroud)

在调试器中,我发现thisValue ="PassingTest"

请指导如何让thisValue只包含"PassingTest"作为值而不是pointeraddress.

Rup*_*Rup 5

这就是char*的工作原理 - 它们是指向内存中字符的指针.如果你想有一个字符串,它支持您可以使用值std::string#include <string>.

使用char*s,您可以使用

if (strcmp(thisValue, "PassingTest") == 0)
Run Code Online (Sandbox Code Playgroud)

如果您不打算修改函数中的字符串内容,则可以接受const char* thisValue而不仅仅是char* thisValue.