Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

oto76mm

How to copy RECT ?

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

I have a RECT with value in it RECT Dest[2]; now I have a new RECT RECT source[2]; how to make source equal Dest the easy way rather than the long method source[0].top = Dest[0].top; source[0].bottom = Dest[0].bottom; . . . . source[1].left = Dest[1].left; source[1].right = Dest[1].right;

Share this post


Link to post
Share on other sites
Advertisement
Given that RECT is a structure with just data members, it's safe to use memcpy:

memcpy(Dest, Source, 2 * sizeof(RECT));

If you were using the CRect class, then you could use the overloaded equal operator to perform a C++ style loop copy:

std::copy(source, source + 2, Dest);

This allows the class to do anything it needs to on assignment.

[edited by - Zipster on March 17, 2003 7:22:50 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
i guess a memcpy would work fine.

Share this post


Link to post
Share on other sites

  • 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!