fork download
  1. #include <stdio.h>
  2. #include <stdint.h>
  3. #include <arpa/inet.h> // Required header for ntohl()
  4.  
  5. int main() {
  6. uint32_t network_value = 1946157056; // Example value in hex (or use an integer)
  7. uint32_t host_value = ntohl(network_value);
  8.  
  9. // Print both values to see the conversion
  10. printf("Network Order (Hex): 0x%X\n", network_value);
  11. printf("Host Order (Hex): 0x%X\n", host_value);
  12. printf("Host Order (Decimal): %u\n", host_value);
  13.  
  14. return 0;
  15. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
Network Order (Hex): 0x74000000
Host Order (Hex):    0x74
Host Order (Decimal): 116