fork download
  1. //#pragma comment(lib, "ws2_32.lib")
  2.  
  3. #include <stdio.h>
  4. //#include <WinSock2.h>
  5. #include <arpa/inet.h>
  6.  
  7. int main()
  8. {
  9. char str1[2] = { 0x00, 0x06 };
  10. char str2[2] = { 0x04, 0xD2 };
  11. int result;
  12.  
  13. result = ntohs(*(u_short*)str1);
  14. printf("%d\n", result);
  15. result = ntohs(*(u_short*)str2);
  16. printf("%d\n", result);
  17. return 0;
  18. }
  19.  
Success #stdin #stdout 0.01s 1720KB
stdin
Standard input is empty
stdout
6
1234