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

前端 未结 4 1358
旧时难觅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:09

    void int64ToChar(char mesg[], int64_t num) {
        *(int64_t *)mesg = num; //or *(int64_t *)mesg = htonl(num);
    
    }
    

提交回复
热议问题