How to send integer with pipe between two processes!

前端 未结 4 1729
情深已故
情深已故 2021-02-05 12:12

I am trying to send an integer with pipe in a POSIX system but write() function is working for sending string or character data. Is there any way to send integer wi

4条回答
  •  时光取名叫无心
    2021-02-05 12:20

    Either send a string containing the ASCII representation of integer e.g., 12345679, or send four bytes containing the binary representation of int, e.g., 0x00, 0xbc, 0x61, 0x4f.

    In the first case, you will use a function such as atoi() to get the integer back.

提交回复
热议问题