?? byteorder.cc
字號:
#include <iostream>using namespace std;#include <netinet/in.h>void showbytes(void* addr, int size){ unsigned char* p=(unsigned char*)addr; for(int i=0; i<size; i++) cout << hex << (int)*p++ << ' '; cout << endl;}int main(){ int n=0x1; showbytes(&n, sizeof(n)); n = htonl(n); showbytes(&n, sizeof(n)); cout << "n=" << n << endl; n = ntohl(n); cout << "n=" << n << endl;}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -