• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 184
  • Last Modified:

simple data type conversion

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?
0
jtm082698
Asked:
jtm082698
  • 3
  • 3
1 Solution
 
kellyjjCommented:
you could type cast it.

int x=65;
char a;

a= (char ) x;
0
 
billcavCommented:
Look in your help for itoa() or ltoa(), which convert intTOascii and longTOascii respectively.

0
 
nietodCommented:
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.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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


0
 
nietodCommented:
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.
0
 
billcavCommented:
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.


0
 
nietodCommented:
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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now