c++ - Issue with Conversion from struct to char * -
i have struct of size 57 bytes when convert char *, size of char * variable shows 4 bytes. problem this?
code:
struct overhead{ unsigned char flags; unsigned short int seqno, timediff, threshold, length; }; struct payload{ double forcex,forcey,forcez,positionx,positiony,positionz; }; struct packet{ overhead fields; payload data; }; packet pack; // assigning values struct members. char * message = (char *)pack; retval = send(conn_socket, message , sizeof(message), 0); edit:
at receiver, if char * typecasted packet *, strut members not values assigned @ sender. why so?
char* pointer (i.e. memory address) 32 bit (on 32 bit platform); 4 bytes.
Comments
Post a Comment