How do I convert a 64bit integer to a char array and back?

前端 未结 4 1357
旧时难觅i
旧时难觅i 2020-12-08 23:20

I am having trouble converting a int64_t to a char array and back. I don\'t know what is wrong with the code below, it makes complete logical sense to me. The code works for

4条回答
  •  失恋的感觉
    2020-12-09 00:13

    In charTo64bitNum you need to cast the char to 64-bit before you shift it:

    (((int64_t)a[0] << 56) & 0xFF00000000000000U)
    

提交回复
热议问题