大家可以确定下面的输出什么吗?
string a = "hello world";
string b = a;
if (a == b)
{
cout << "true"<<endl;
}
else
{
cout << "false"<<endl;
}
if (a.c_str() == b.c_str())
{
cout << "true" << endl;
}
else cout << "false" << endl;
string c = b;
c = "";
if (a.c_str() == b.c_str())
{
cout << "true" << endl;
}
else cout << "false" << endl;
a = "";
if (a.c_str() == b.c_str())
{
cout << "true" << endl;
}
else cout << "false" << endl;
return 0;
vs2017 debug x64 输出 T F F F
g++ 4 输出 T T T T