I have a checksum256 type, I want to reach its specific elements as an integer. Ex

cheksum256 myvar = 3dd6a4a0c86763d2a6fc1d5544eb58f3953b7cd03882e700b420fa0a89129f66;

I want myvar[0] and myvar[2] as an int type.

1 Answer 1


Not sure if i get the question right, probably something like this is what you looking for.

auto checksumBytes = myvar.extract_as_byte_array().data();
uint64_t num1, num2;
memcpy(&num1, &checksumBytes[0], sizeof(num1));
memcpy(&num2, &checksumBytes[7], sizeof(num2));
  • Thank you for your answer but I get this error: error: array initializer must be an initializer list or string literal unsigned char checksumBytes[32] = myvar.extract_as_byte_array().data();
    – Mali
    Apr 2, 2019 at 15:01
  • sry, use auto "checksumBytes" instead of "unsigned char checksumBytes[32]"
    – cmadh
    Apr 4, 2019 at 23:19
  • Thank you very much
    – Mali
    Apr 5, 2019 at 10:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.