I have searched both google and forums and cannot figure out how get a substring from CCString or to compare if CCString contains a substring.
Using cocos2d-x v2.0
Simply get string from it.
CCString* pString = CCString::create("Hello world");
std::string hello = pString->m_sString.substr(0,5);
also could use pString.getCString(); which return const char*
take a look in CCString.h
/** get the C string /
const char getCString() const;
not sure please try.
Thanks for responses …
@gelldur - What is m_sString in the second line?
It attribute std::string in CCString which save string you assign to CCString
Go to class and checkout.
m_sString is a std::string
okay thanks birdcpe25
One last question…
How do I convert the std::string hello back to CCString pString?
create the new CCString one for pString
or assign m_sString directly
std::string m_sString; << this one is public then you could do whatever you want with this thing