0

I got this string

0x3384BCFD
0x61CEB13B

both are of string type..

Initially I got this

uint32_t iv[2]  = {0xFFFFFFFF,0xFFFFFFAA};

How do I assign the 2 string above into iv[0] and iv[1]?

I want the final result of iv[2] as iv[2] = {0x3384BCFD,0x61CEB13B};

Thanks for helping!!

Fabio
  • 23,183
  • 12
  • 55
  • 64
user1777711
  • 1,604
  • 6
  • 22
  • 32

3 Answers3

5

Seeing as how this isn't in the linked dupe:

uint32_t iv[] = { //*cough* std::array exists as well
    std::stoul(strs[0], nullptr, 16), 
    std::stoul(strs[1], nullptr, 16)
};
chris
  • 60,560
  • 13
  • 143
  • 205
4

Since it's C++ I suggest you to use streams with manipulators:

stringstream ss = stringstream("0x3384BCFD");
ss >> hex >> iv[0];
Jack
  • 131,802
  • 30
  • 241
  • 343
2
#include <sstream>

int main()
{
    uint32_t iv[2];

    std::stringstream("0x3384BCFD 0x61CEB13B") >> std::hex >> iv[0] >> iv[1];
}
David G
  • 94,763
  • 41
  • 167
  • 253