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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

815 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

8 Experts available now in Live!

Get 1:1 Help Now