数据大小端64位字节序转换(__int64类型数据从小端转换为大端

  //////__int64类型数据从本机(小端)转换为网络字节序
	__int64 i64_host;		//本机(小端)
	__int64 i64_net;		//网络字节序(大端)
	int i32_host_h;		
	int i32_host_l;  

	i32_host_l = i64_host & 0xffffffff;  
	i32_host_h = (i64_host >> 32) & 0xffffffff;  

	i64_net = htonl(i32_host_l);  
	i64_net = ( i64_net << 32 ) | htonl(i32_host_h);  
	///测试输入
	i64_host = 8127137442444691200;
	///测试输出
	i64_net = 20180202095430000;

 
 

猜你喜欢

转载自blog.csdn.net/wushuangge/article/details/79236609