为什么以下不将这两个字符解释为一组 16 位?
char c[2];
c[0] = 2;
c[1]= 2;
short a = short(c[0]);
我想要两个一起读取数组的所有 16 位吗?最快(延迟)的方法是什么?
最佳答案
您必须写入实际的短片。你可以这样做:
short a;
unsigned char * p = reinterpret_cast<unsigned char *>(&a);
p[0] = 2;
p[1] = 2;
关于c++ - 从数组中读取 2x 个字符作为短字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24687688/