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

x
?
Solved

Cast from DWORD to string

Posted on 2000-05-15
4
Medium Priority
?
2,946 Views
Last Modified: 2012-06-27
A beginer questin:
How do I cast a from Dword to string ?
Thank's

AA
0
Comment
Question by:arnonayal
[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
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
tvanceplus earned 200 total points
ID: 2811983
Here is some code that could do it.

/*code  myword already contains desired value*/

__int64 temp;
temp=myword;
char buffer[50];

_i64toa(temp,buffer,10);

CString str=buffer;

/*end code*/

Good Luck!
0
 
LVL 22

Expert Comment

by:nietod
ID: 2812095
A DWORD is 32 bits, not 64, so you could use _itoa(), not __i64toa().  (Although i64toa() would work, its overkill.).

However this is not a portable solution--if that matters.  A portable solution would be to use sprintf() or to output the information to a string stream object and then obtain the string from the string stream object.
0
 
LVL 1

Expert Comment

by:tvanceplus
ID: 2812411
It could be overkill. I was not sure whether or not the fact that DWORD was an unsigned value would cause overflow for the integer conversion function parameter.
0
 
LVL 22

Expert Comment

by:nietod
ID: 2812716
Good point.  if the DWORD is outside of the signed int range you would need to use i64toa().
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

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses

618 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