We help IT Professionals succeed at work.

simple data type conversion

jtm082698
jtm082698 asked
on
193 Views
Last Modified: 2010-04-10
I have an int or a long whose value I want to check via a messagebox, but I need to convert it into a data type that the messagebox will display. How is it converted?
Comment
Watch Question

Commented:
you could type cast it.

int x=65;
char a;

a= (char ) x;
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Commented:
itoa() etc are microsoft specifc functions.  If you want to use a more portable function (of course you are working in windows so portability is not a big issue) you can use sprintf()  That is a standard function that is available in all C++ implimentations.

Commented:
When did Xtoa() become Microsoft-specific? I've used them in *NIX programs for more than half a decade. They reside in stdlib.


Commented:
microsoft specific might have been pushig it a little.  They are not part of the C++ standard so some implimentations will not support them.  But obviously some do other than microsoft.

Commented:
Didn't they become part of the ANSII C standard four or five years back? I think the official implementation was as macros. IIRC, the C++ proposed standard has been built on the C standard, so it should include the xtoa() and atox() functions/macros.

BTW, the reason to use them instead of sprintf() is probably moot. With the current state of optimizers and the current speed of processors and size of hard drives and memory the TINY performance/code size benefit is probably not worth thinking about.


Commented:
According to the Microsoft docs they are not standard and it is a well know fact that Microsoft is never wrong.  : - )  The argument is moot from both sides, since this is a windows application, portability can't be that big an issue anyways.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.