Surely I can't use sizeof(message) though...
That's going to be 4 bytes wihch is wrong as the message could be up to 300 bytes long...
Printable View
Surely I can't use sizeof(message) though...
That's going to be 4 bytes wihch is wrong as the message could be up to 300 bytes long...
Yes, this is true. But I'm not sure what the solution iMalc had in mind is.
The way it stands I have little choice as the program I'm communicating with is already made and cannot be changed.
I need to send one buffer in the form:
[<- 12 bytes of header->][<- variable length up to 64 bytes - of options->][-< variable length up to 300 bytes - of message->]
There's no way to change that.
I doubt sending the sizeof(options) (= 64) is a good plan, because it will expect 64 bytes of options probably. Most of the time only the first 2 elements of the array are set.
Then make it fixed.
Use 12 bytes, 64 bytes and then 300 bytes.
No hassle with size and it will be easy to gut the data when received at the other end.
Can you explain what you mean please?
Thanks.
Actually, I think I will make it so that the message is no longer passed in as an argument and I could just get the message inside the function and that way, both options and message will be local arrays inside the function and I will be able to sue sizeof without any problems.