Solved

Hexadecimal String to uint64_t

Posted on 2011-03-11
3
2,040 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

Industry Leaders: 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

Suggested Solutions

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

710 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