Convert Integer into a string

OrionVeteran

Deity
Joined
Dec 25, 2003
Messages
2,443
Location
Newport News VA
Hopefully, this is an easy question. I am currently using the following format to create SDK string messages for debugging.

Code:
int iNumberValue;
CvWString szBufferA;

szBufferA = "A";

gDLL->getInterfaceIFace()->addMessage(getOwnerINLINE(), true, GC.getEVENT_MESSAGE_TIME(), szBufferA, "AS2D_COMBAT", MESSAGE_TYPE_DISPLAY_ONLY, getButton(), (ColorTypes)GC.getInfoTypeForString("COLOR_RED"), pUnitPlot->getX_INLINE(), pUnitPlot->getY_INLINE(), true);

How can I change the code to convert an integer value (iNumberValue) into a string so that I can display the integer value in the message?
 
szBufferA.Format(L"%d", iNumberValue);

You can also do things like
szBufferA.Format(L"Player %d (%s) built a unit in city %s", iPlayer, GET_PLAYER(iPlayer).getName(), pCity->getName().GetCString());

The difficult part is knowing when you need to use GetCString and when you don't. You can try without it and if you get garbage try with it.
 
Back
Top Bottom