Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

INT to String

Posted on 2012-03-09
3
Medium Priority
?
383 Views
Last Modified: 2012-08-13
This shouldn't be this difficult....

I have a global variable:

correctKey = 1;

Open in new window


I want to do some debugging, and MessageBox the value sometimes.

So, I init a CHAR with an extra spot for the terminating 0, right?

char ck[2];

Open in new window


then I assign that to the INT value, right?

    ck = correctKey;

Open in new window


Then try to debug message.
    MessageBox(NULL,"Correct Key Is...", ck,NULL);[code]

Open in new window


I have tried using std::string, atoi , c_str() , etc. Apparently, I haven't figured out the right combination.

Thanks,
0
Comment
Question by:edvinson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 41

Accepted Solution

by:
Kyle Abrahams earned 2000 total points
ID: 37703347
char ck;

ck = itoa(correctKey);  //  http://www.cplusplus.com/reference/clibrary/cstdlib/itoa/

and not sure if you have to append it as one message:

 MessageBox(NULL,"Correct Key Is..." + ck,NULL);
0
 
LVL 1

Author Comment

by:edvinson
ID: 37703587
Hmmm, thats not working either.
0
 
LVL 1

Author Comment

by:edvinson
ID: 37703613
Got it

 int myNumber = 1;

                    char myChar[2];

                    itoa (myNumber,myChar,10);

                    MessageBox(hwndDlg, myChar, "Information", MB_ICONINFORMATION);
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question