我是C++编程新手.我正在尝试实现一个代码,通过该代码我可以从6或更多地生成一个整数值individual bytes.
我已经实现了相同的功能,4 bytes并且它正在工作
我的4字节代码:
char *command = "\x42\xa0\x82\xa1\x21\x22";
__int64 value;
value = (__int64)(((unsigned char)command[2] << 24) + ((unsigned char)command[3] << 16) + ((unsigned char)command[4] << 8) + (unsigned char)command[5]);
printf("%x %x %x %x %x",command[2], command[3], command[4], command[5], value);
Run Code Online (Sandbox Code Playgroud)
使用此代码的值value是,82a12122但是当我尝试6字节时,结果是错误的.
代码为6字节:
char *command = "\x42\xa0\x82\xa1\x21\x22";
__int64 value;
value = (__int64)(((unsigned char)command[0] << 40) + ((unsigned char)command[1] << 32) + ((unsigned char)command[2] << 24) + ((unsigned char)command[3] << 16) …Run Code Online (Sandbox Code Playgroud)