Jump to content
  • Advertisement
Sign in to follow this  
y2jsave

are these same

This topic is 3674 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

are these same memcpy(&(dest_addr.sin_addr),host->h_addr,host->h_length); and dest_addr.sin_addr = host->h_addr;

Share this post


Link to post
Share on other sites
Advertisement
No. memcpy copies the memory from one place to another, meaning you have the original and a new copy, both of which are contain the same data (they are two separate copies though), but you can modify the new copy all you want and the original won't get changed (because it's a separate copy). Your second line of code doesn't copy anything. Instead, it just makes it so that two pointers point to the same piece of memory, so if you modify that memory through dest_addr.sin_addr, then the memory that host->h_addr points to is also modified (because the memory is "shared" between the two).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!