对std::string 直接用 ==
对char* 应该用strcmp()
string t1 = "helloWorld"; string t2 = "helloWorld"; if (t1 == t2) { printf("***t1 ,t2 是一样的 "); printf("这是正确的 "); } if (t1.c_str() == t2.c_str()) { printf("@@@t1 ,t2 是一样的 "); } if (strcmp(t1.c_str(),t2.c_str()) == 0) { printf("###t1 ,t2 是一样的 "); printf("这是正确的 "); } --------------------- 作者:wisdom605768292 来源:CSDN 原文:https://blog.csdn.net/wisdom605768292/article/details/12076375 版权声明:本文为博主原创文章,转载请附上博文链接!