1、可以采用取整和取余的方式实现:

高低位数据分离的两种方法

 

2、可以采用移位的方式实现:

#include <stdio.h>

int main(int argc, char **argv)

{

  int test = 0x2345;

  printf("%#x\r\n", (test >>8) & 0xff);

  printf("%#x\r\n", test & 0xff);

  return 0;

}

 

当然,还有其他很多方式,此处仅这两种做记录。

 

相关文章:

  • 2022-12-23
  • 2021-12-10
  • 2022-12-23
  • 2021-11-23
  • 2022-02-07
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-21
  • 2021-11-06
相关资源
相似解决方案