Solved

Hexadecimal String to uint64_t

Posted on 2011-03-11
3
2,098 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 31

Accepted Solution

by:
Zoppo earned 400 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 100 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

632 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