【发布时间】:2015-02-13 18:34:04
【问题描述】:
我已经编写了一个函数来解析字符串参数作为我项目的一部分。功能一切正常,但我收到一条警告,上面写着:C4018: '<' : signed/unsigned mismatch。我不知道为什么会出现这个警告。我可以在这里得到一些帮助。谢谢!
void FileMgr::parseCmdLineForTextSearch(std::string b)
{
int count=0;
int flag = 0;
patternVector.clear();
for (int i = 0; i < b.length(); i++) // this line where
// the warning line comes
{
if (b[i] == '"')
{
count++;
}
}
if (count == 2)
{
for (int i = 0; i < b.length(); i++)
{
if (b[i+1] == '"')
{
flag = 1;
tmp = b.substr(0, i+1);
tmp.erase(0, 1);
break;
}
else
{
continue;
}
}
std::istringstream iss(b);
std::string word;
while (iss >> word)
{ // for each word in b
if (word.find("*.") == 0)
{ // if it starts with *.
patternVector.push_back(word); // add it
}
}
if (patternVector.size() == 0)
{
patternVector.push_back("*.*");
}
isCorrect = true;
}
else
isCorrect = false;
}
【问题讨论】:
-
修复它,我认为警告是错误的(虽然你的线路会表现良好,其他可能不会)
标签: c++