码迷,mamicode.com
首页 > 其他好文 > 详细

高低位字节互换

时间:2015-03-14 17:04:44      阅读:121      评论:0      收藏:0      [点我收藏+]

标签:

#include <iostream>
#include <iomanip>

using namespace std;
int main()
{
	unsigned short A =0xABCD;
	unsigned short B,C,D;
	
	cout<<setiosflags(ios::uppercase)
		<<hex
		<<"A =0x "
		<<A<<endl;

	B = (A<<8)&0xff00;
	C = (A>>8)&0x00ff;
	D = C|B;
	cout<<"B =0x "<<B<<endl
		<<"C =0x "<<C<<endl
		<<"D =0x "<<D<<endl;
	return 0;
}
技术分享

高低位字节互换

标签:

原文地址:http://blog.csdn.net/chentravelling/article/details/44260161

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!