Archived

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

How to copy RECT ?

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 on other sites
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 on other sites
i guess a memcpy would work fine.

• Forum Statistics

• Total Topics
628334
• Total Posts
2982147

• 9
• 24
• 9
• 9
• 13