Sign in to follow this  

are these same

This topic is 3486 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

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

This topic is 3486 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this