Cast from DWORD to string

Posted on 2000-05-15
Last Modified: 2012-06-27
A beginer questin:
How do I cast a from Dword to string ?

Question by:arnonayal
  • 2
  • 2

Accepted Solution

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

/*code  myword already contains desired value*/

__int64 temp;
char buffer[50];


CString str=buffer;

/*end code*/

Good Luck!
LVL 22

Expert Comment

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.

Expert Comment

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.
LVL 22

Expert Comment

ID: 2812716
Good point.  if the DWORD is outside of the signed int range you would need to use i64toa().

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
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…
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 use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

914 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now