Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Hexadecimal String to uint64_t

Posted on 2011-03-11
3
Medium Priority
?
2,262 Views
Last Modified: 2012-05-11
Hey guys,

How can I convert this?

std::string macAddress = "0x0493934FF3";

into a uint64_t?  I know atoi can pack a hex string into a 32-bit integer but I have no idea how to get it into a 64-bit integer which is how our system stores MAC addresses.  I need this ability to read the XML strings from our configuration into the system.

Thanks!

-w00te
0
Comment
Question by:w00te
  • 2
3 Comments
 
LVL 31

Accepted Solution

by:
Zoppo earned 1600 total points
ID: 35109743
Hi w00te,

you could use a stringstream, i.e. like this:
	__int64 n;
	std::stringstream ss;
	ss.str( macAddress );
	ss >> std::hex >> n;
	// check it
	std::cout << std::hex << n << std::endl;

Open in new window


Hope that helps,

ZOPPO
0
 
LVL 31

Expert Comment

by:Zoppo
ID: 35109750
ah - sorry, forgot to say you need to

#include <sstream>

Open in new window

0
 
LVL 86

Assisted Solution

by:jkr
jkr earned 400 total points
ID: 35109872
Just for the sake of completeness - there's also '_strtoui64()': http://msdn.microsoft.com/en-us/library/85zk715d%28VS.80%29.aspx (scroll down for the example)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

876 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