Thread: Binary Copy

  1. #1
    Registered User
    Join Date
    May 2004

    Binary Copy

    If I had this...
    struct PointType
       int x;
       int y;
    struct RectangleType
       PointType topLeft;
       PointType extent;
    ...and this...
    struct RCType
       int Col;
       int Row;
       int Cols;
       int Rows;
    ...could I safely binary copy one over to the other?...
    RectangleType Rect = { { 4, 2 }, { 40, 24 } };
    RCType RC = *( (RCType*)&Rect );
    It seems like it should work, but I don't know how the compiler organizes structures.

  2. #2
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Its actually quite simple:

    You don't. Reason being is that the compiler is allowed to make some adjustments that would screw up any bitwise (not binary) operations.

    Best method would be to write a constructor that took in two points and made a rectangle out of them.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. denary to binary problems
    By redruby147 in forum C Programming
    Replies: 6
    Last Post: 02-09-2009, 05:21 PM
  2. how to copy binary files using Unix API's
    By rohan_ak1 in forum C Programming
    Replies: 25
    Last Post: 05-07-2008, 09:12 AM
  3. I need help with decimal to binary Algorithm
    By webznz in forum C Programming
    Replies: 4
    Last Post: 03-13-2008, 03:52 AM
  4. arrays vs lists? And containers in general!
    By clegs in forum C++ Programming
    Replies: 22
    Last Post: 12-03-2007, 02:02 PM
  5. binary
    By webturtle0 in forum A Brief History of
    Replies: 52
    Last Post: 12-05-2002, 02:46 AM