Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Hexadecimal math in vc++

2 views
Skip to first unread message

Shadowboxer.org

unread,
Jan 8, 2004, 5:19:14 AM1/8/04
to
I need to do some math on a cdkey for an msi, I essentially have 7 blocks of
numbers that are hex-encoded by Vb.net

eg FFFF = 65535

what I need to do is get the number (decimal) back from the String (hex)

the items are stored in character arrays sA[4] and sB[9]

I need to run a formula on the two values but first I need to get their
numeric representation out. is there any built in function that can do this?

in vb it's simple:

key = "FDE4"
dim hexString as integer = cInt("&H" & key)

essentially casting, is there an equivalent method in vc7.

I need to stay away from the CLR since this is a setup dll and there may be
no Framework on the machine.


Thanks Bunches! -Shadow


Hendrik Schober

unread,
Jan 12, 2004, 8:38:29 AM1/12/04
to
Shadowboxer.org <shado...@nospam.shadowboxer.org> wrote:
> [...]

> I need to run a formula on the two values but first I need to get their
> numeric representation out. is there any built in function that can do this?

#include <sstream>

int readFromHex(const char* sz)
{
int i;
std::istringstream iss( sz );
iss >> i;
if( !iss ) {
throw error(sz);
}
return i;
}

> [...]
> Thanks Bunches! -Shadow


Schobi

--
Spam...@gmx.de is never read
I'm Schobi at suespammers dot org

"Sometimes compilers are so much more reasonable than people."
Scott Meyers

0 new messages