Making and sending a mix double and int array in c -
i trying send msg socket in form on
double,int,int,int,int,...,int
n int values how can send it? have opened socket how can put elements in 1 array sent in:
status=sendto(sendsocket,msg,sizeof(double)+n*sizeof(int), 0,(void*)&out_socketaddr,sizeof(out_socketaddr));
where msg memory(array) of elements , out_socketaddr destination
uint8_t array [sizeof(this) + sizeof(that) + ...]; uint8_t* ptr = array; memcpy(ptr, &this, sizeof(this)); ptr+=sizeof(this); memcpy(ptr, &that, sizeof(that)); ptr+=sizeof(that); ...
avoid making struct. although structs make code more readable, introduce padding, issue in case.
Comments
Post a Comment