Original Post
Alright, this is not some dumb question about how (I know about itoa() ), but about a problem that it causes me. When it changes a number from its original form to a string, it cuts out any 0's before the actual numbers. Is there a way I can get it to leave these in?
Example:
long lMyNum = 0x0000F8AC;
char *cpMyString;
cpMyString = new char[8];
itoa(lMyNum,cpMyString,16);
cout << ":" << lMyNum << ":" << endl;
This small bit of code writes out ":F8AC:". I want it to write out ":0000F8AC:". This way, I can use it with my sockets stuff, and just place the length as a 4-byte ascii value (translated to a WORD via atoi(), and yes, I know I used a DWORD in the example), without having to put another single-character value in front of that (telling the length of the value that tells me the length of the rest of it).
----What I want:
string: "Four"
length: 4
send it as: 04Four
----What I have to do now:
string: "Four"
length: 4
sends as: 104Four
Granted, it is not a whole lot of work to do, it is just annoying...
[edited by - zackriggle on April 19, 2003 4:53:58 PM]