void huffmanDecode(string str){
string temp;
map<string, char>::iterator it;
//for(auto iter=myMap.begin();iter!=myMap.end();++iter)
//cout<<iter->first<<" "<<iter->second<<" "<<endl;
for (unsigned int i = 0; i < str.size(); i++)
{
temp += str[i];
it = myMap.find(temp);
if (it == myMap.end())
continue;
else
{
cout<<it->first<<" ";//crashed here, "Thread 1:EXC_BAD_ACCESS(code=1,address=0x0)
//cout << it->second << " ";
temp = nullptr;
}
}
}
我試圖通過地圖解決huffmandecode問題,但它墜毀~~~問題有關地圖STL
你真的不想做這樣的:'溫度= nullptr;'。這可能是墜機的原因。 – juanchopanza 2014-11-05 09:05:28
我會嘗試一下。那麼temp = NULL如何? – Jimmy 2014-11-05 09:07:25
嘗試temp.clear() – 2014-11-05 09:07:50