fork download
  1. #include <iostream>
  2. #include <netinet/in.h>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. unsigned short i = 0x3313;
  8. cout << i << endl;
  9. cout << showbase << hex << i << endl;
  10.  
  11. i = htons(i);
  12. cout << i << endl;
  13. cout << showbase << hex << i << endl;
  14.  
  15. return 0;
  16. }
Success #stdin #stdout 0s 5308KB
stdin
Standard input is empty
stdout
13075
0x3313
0x1333
0x1333