Hi…
I’m working on a word based game , so there I need to verify a word with the words in english dictionary.For That I have a text file with a list of english words…
Now I have to make a Dictionary object to key and use the words…. how to do that? can anyone tell me with an example…
I tried this…
CCMutableDictionary < std::string, std::string > *plistDictionary=new CCMutableDictionary < std::string,std::string > ;
FILE *fp = fopen(fileName, "r");
char buf[50] = {0};
if (!fp)
{
CCLOG("can not open file %s", fileName);
return;// NULL;
}
else
{
fgets(buf, 50, fp);
plistDictionary->setObject(buf,buf);
CCLOG("read content %s", buf);
fclose(fp);
}
But I’m getting error in the line of initializing CCMutableDictionary Object
CCMutableDictionary < std::string, std::string > *plistDictionary=new CCMutableDictionary < std::string,std::string > ;
// error show the line pObject->retain() .. /cocos2dx/include/CCMutableDictionary.h:206:9:{206:9-206:19}: error: value of type 'std::basic_string < char > ' is not contextually convertible to 'bool' [3]
can’t I use the string type for the ValueType or KeyType
and in the line of inserting Object into the dictionary
plistDictionary->setObject(buf,buf);
// error show the line pObject->retain() .. cocos2dx/include/CCMutableDictionary.h:122:11:{122:4-122:11}: error: member reference type 'std::basic_string < char > ' is not a pointer [3]
someone help….