How to get size of variable -- e.g sizeof(int) + network optimization

Variable Sizes

How can I determine the size of a given variable? Trying to optimize network traffic but I don’t know the sizes of everything, and google isn’t helping much.

If there’s no way, then could someone tell me how the size of, for example, a structure is determined? Would a struct with 2 bytes, 1 int, and 1 string, be 22 bytes total?

And what about arrays? e.g. would an integer array with 4 indexes be 16 bytes?

**Network Optimization **

What is the correct way to optimize network traffic? Go for the absolute lowest amount of data sent? Here’s the last thread I made about this:

In that thread, William Crawford said that even if the “communication” is a single byte - the “packet” will still be a certain size. Does that mean that if, for example, the server sends the client a structure variable with only two bytes, that the “communication” total will be larger? And if this is the case, would that mean that if the data being sent was a single byte larger than the packet size… that it would send two packets? So confusing! Sorry if that didn’t make sense.

Also, if a client-server communication happens, is that considered… one packet? (assuming the data is small enough?)