Archived

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

oto76mm

How to copy RECT ?

Recommended Posts

oto76mm    122
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
Zipster    2365
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