Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert int to string

Status
Not open for further replies.

WebdudeIA

Programmer
Jul 26, 2002
11
0
0
US
Here's a simple piece of code.
------------------
int nMyDimes;

nMyDimes = 0;

if (GetValue(1, nMyDimes) == TRUE)
{
AfxMessageBox("Value is GetValue is " + nMyDimes);
}
------------------
How do I convert nMyDimes to a string so that this displays correctly?
 
Either use itoa() to convert the integer to text on the fly:
Code:
AfxMessageBox("Value of GetValue is " + itoa(nMyDimes));

or use sprintf() to pre-format the entire string before displaying it:

Code:
char sMessage[100];
sprintf(sMessage, "Value of GetValue is %i", nMyDimes);
AfxMessageBox(sMessage);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top