我遇到了一個問題,在特定的函數中使用stricmp,在其他函數中它完美地工作,除了這一個。 問題是即使它比較相同的字符串(char *)也不會返回0. 可能是什麼問題? (抱歉的混亂,我會嘗試進行格式化) 是這樣的代碼:stricmp不起作用
Employee* CityCouncil::FindEmp(list<Employee*> *lst, char* id)
{
bool continue1 = true;
Employee* tmp= NULL;
char* tmpId = NULL, *tmpId2 = NULL;
list<Employee*>::iterator iter = lst->begin();
if ((id == NULL) || (lst->empty()==true))
return NULL;
while ((iter != lst->end()) && (continue1)){
tmp = (Employee*)(*iter);
tmpId = (*tmp).GetId();
if(tmpId != NULL)
{
if(stricmp(tmpId,id) == 0)
continue1 = false;
}
if (continue1 == true)
iter++;
}
if (iter == lst->end())
return NULL;
return (Employee*)(*iter);
}
請在發佈問題時使用預覽。這次更正了源碼格式。 – AndiDog 2010-09-11 17:21:03
請用語言(C/C++?)標記問題。 Visual Studio支持多種語言,因此您需要更具體。 – Oded 2010-09-11 17:23:56
根據MSDN - http://msdn.microsoft.com/en-us/library/ms235365(v=VS.100).aspx - 'stricmp'現已被棄用。您應該使用'_stricmp'來替代 - http://msdn.microsoft.com/zh-cn/library/k59z8dwe.aspx – ChrisF 2010-09-11 17:24:53