3

Convert a string to a unsigned long long.

string str = "0x1232"

How do I convert to a unsigned long long.

This is what i've tried.

unsigned long long ull;
ull = stoull(str, NULL, 0);

Error:

 error: identifier "stoull" is undefined
                        ull = stoull(str, NULL, 0);

Can you give me some pointers?

pistal
  • 2,310
  • 13
  • 41
  • 65

1 Answers1

8

First of all it's strtoull (notice the r). Second of all, it's an old C-style function and can't handle std::string directly. You either have to pass it str.c_str() or use the new std::stoull.

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621