Hey,
So say I have a sockaddr_in struct stored in a packet which I receive
from my udp socket.....and it is stored within a certain offset into
this packet (which is basically a char array). Currently, the first
four bytes store an ID information and the next sizeof(struct
sockaddr_in) bytes store this struct.
Now, say that i declare a struct sockaddr_in temp_addr variable...would
the following lines be valid??
//we fill up char* buff using the recvfrom function
//we declare following struct
struct sockaddr_in addr;
memcpy ( (void *)&(addr),(void *)buff,sizeof(struct sockaddr_in));
So basically, my question is are structs stored contiguously in memory?
So can I copy entire structs from one location to another? Or do I have
to copy individual values of the struct (such as port number etc) from
buff to addr?
I'm sorry if my question is not making sense, but I can elaborate if
needed...
Thanks,
Ravi Sathyam