|
-
May 28th, 2002, 10:42 AM
#1
Thread Starter
Hyperactive Member
DWORD to CString
I'm converting a DWORD which represents a CRC to a string.
This works fine but whenever the DWORD is preceded by a
zero, it's truncated and not included in the string.
Code:
_itoa(dwChecksum, buffer, 16);
Is there another way to do this without losing that first zero?
Bababooey
Tatatoothy
Mamamonkey
-
May 28th, 2002, 12:10 PM
#2
Monday Morning Lunatic
You could always convert it, then see how many characters there are.
Or, you could use a stringstream to do it for you:
Code:
#include <iostream>
#include <sstream>
#include <iomanip>
void somecode() {
ostringstream oss;
oss << setw(8) << setfill('0') << 6574;
string whatever = oss.str();
}
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
May 28th, 2002, 12:42 PM
#3
Thread Starter
Hyperactive Member
thx, i had the value in a CString so i just tested to make sure the
length was 8 and added a '0' otherwise
Bababooey
Tatatoothy
Mamamonkey
-
May 31st, 2002, 02:33 AM
#4
Or use the CString::Format function. I works like sprintf.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|