fork download
  1. #include <iostream>
  2. #include <arpa/inet.h>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. long l = -42;
  8. long l2 = ntohl(htonl(l));
  9.  
  10. std::cout << "l2= " << l2 << std::endl;
  11. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
l2= -42