Go to the documentation of this file.00001
00007 #include<my_lib/long_manip.hh>
00008 #include<iostream>
00009
00018 namespace my_lib{
00019
00024 void byte_print(long l) {
00025 struct conf{
00026 conf(){ std::cout << std::hex;}
00027 ~conf(){ std::cout << std::dec;}
00028 } cn;
00029 unsigned char* c = (unsigned char*) &l;
00030 for(unsigned i=0; i<sizeof(long); ++i){
00031 if(i>0)
00032 std::cout << '.';
00033 std::cout << (unsigned) *(c+i);
00034 }
00035 std::cout << std::endl;
00036 }
00037
00043 void byte_swap(void* p, void* q) {
00044 unsigned char & c = *((unsigned char*) p);
00045 unsigned char & d = *((unsigned char*) q);
00046 c^=d; d^=c; c^=d;
00047 }
00048 }