fork download
  1. #include <iostream>
  2. #include <netinet/in.h>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. auto i = ntohs(64);
  8. cout << i << endl;
  9.  
  10. i = htons(0x8100);
  11. cout << i << endl;
  12. short int x = 0x8100;
  13. i = (((x) & 0xff00) >> 8) | (((x) & 0x00ff) << 8);
  14. cout <<"flip" << i<<endl;
  15. i = ntohs(59151);
  16. cout << i << endl;
  17.  
  18. i = ntohl(0x93000000);
  19. cout << i << endl;
  20.  
  21. i = ntohl(0x8d000000);
  22. cout << i << endl;
  23.  
  24. i = ntohl(0x67000000);
  25. cout << i << endl;
  26.  
  27. i = ntohl(0x41000007);
  28. cout << i << endl;
  29.  
  30. i = ntohl(0x0000005f);
  31. cout << i << endl;
  32.  
  33. return 0;
  34. }
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
16384
129
flip129
4071
147
141
103
65
0