标签:-o cocos2d bottom with ccs 最好 att 微软 blog
在做数据转换时,最好包含以下头文件
//int 转 CCstringint num=5; CCString* ns=CCString::createWithFormat("%d",num); //CCstring 转 intint px = ns->intValue();//将CCString 转换为int的方法,转成float类型有 floatValue() //====================================== //CCString 转 charconstchar *string= ns->getCString(); //char 转 CCString CString.Format(”%s”,char *)//char 转cstring CCString* ns=CCString::createWithFormat("%s",char *); //====================================== //string 转 charconstchar *string=std::string("STRING").c_str(); char 转 stringstring s(char *); //====================================== //string 转 int std::string s("1234"); int n = std::atoi(s.c_str());//函数原型int atoi(const char *); //int 转 stringint a=3; CCString* ns=CCString::createWithFormat("%d",a); string s=ns->m_sString; //====================================== //string 转 CCString std::string str = "123"; CCString* ns=CCString::createWithFormat("%s",str.c_str()); CCString 转 string std::string s= ns->m_sString;//ns是一个CCString*类型 //====================================== //char 转 intchar *buf = "1122"; int n = std::atoi(buf); //int 转 charint a=3; CCString* ns=CCString::createWithFormat("%d",a);
类型转换(CCstring int string char UTF-8互转)
标签:-o cocos2d bottom with ccs 最好 att 微软 blog
原文地址:http://www.cnblogs.com/feizuzu/p/4a0fb8ab43bb440dc4198ce5c234cbad.html