Solved

Hexadecimal String to uint64_t

Posted on 2011-03-11
3
1,972 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 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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

770 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