I Need to write the following struct to a fifo:
struct msg_t {
int length;
char* msg;
};
I malloc the struct and the char* inside it and I write like this: (let's assume msg is the variable name) write(fifo_fd, &msg, sizeof(msg_t));
The length is read from the other end just fine. The string isn't.. How can I write those two fields with a single write? If not, are two separate writes good?
Thank you.