What is the correct way to work out how many bytes an int is? and how do I write an int to a file descriptor?
Here is a mock code sample which might make clear what I am trying to achieve:
char *message = "test message";
int length = strlen(message);
int fd = open(file, O_CREAT|O_RDWR);
write(fd, length??, ??); // <--- what goes here
write(fd, message, length);
I dont care about platform independence and byte order, just that it can compile on as many platforms as possible.