【发布时间】:2015-02-17 10:21:30
【问题描述】:
这是我的代码:
const TiXmlAttribute* pAttr = pElem->FirstAttribute();
const char* name = pAttr->Name(); // attribute name
const char* value = pAttr->Value(); // attribute value
float _D = 0.0;
if("SRAD" == name) // returns false here, but name is indeed "SRAD"
{
_D = atof(value);
}
问题是名称是“SRAD”,但 if 条件返回 false。有人教我为什么吗?谢谢。
【问题讨论】:
-
您正在比较指针。而是比较字符串。
-
想在这里发布一些代码吗?
-
没有。查一下。这是微不足道的,有两千万个重复。