fork(1) download
  1. #include <fcntl.h>
  2. #include <unistd.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <stddef.h>
  7. #include <sys/types.h>
  8. #include <sys/socket.h>
  9. #include <netinet/in.h>
  10.  
  11. int main(void) {
  12.  
  13. float freq_rang=1.234;
  14. char msg[100] = {0};
  15.  
  16. *((float*)&msg[3]) = (float)(htonl(freq_rang));
  17.  
  18. printf("%02x %02x %02x %02x \n", msg[3],msg[4],msg[5],msg[6]);
  19.  
  20. memcpy(&msg[3], &(float){htonl(freq_rang)}, sizeof(float));
  21.  
  22. printf("%02x %02x %02x %02x \n", msg[3],msg[4],msg[5],msg[6]);
  23.  
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
00 00 ffffff80 4b 
00 00 ffffff80 4b