title: Loss of information while structure casting
body: <p>I'm passing a struct by typecasting it as an integer.
  On the output, printBook(), I'm re-acquiring the socket, by typecasting the typed passed integer.</p>
  
  <p>Expected output:-</p>
  
  <pre><code>Book id : 11
  Book no of copies : 2
  Book id : 12
  Book no of copies : 10
  </code></pre>
  
  <p>Actual Output</p>
  
  <pre><code>Book id : 11
  Book no of copies : 0
  Book id : 12
  Book no of copies : 0
  </code></pre>
  
  <p>Why am I losing partial data?
  Here's the snippet.</p>
  
  <pre><code>#define UINT16 int
  
  typedef  unsigned int UINT32;
  using namespace std;
  
  #include &lt;iostream&gt;
  #include &lt;cstring&gt;
  
  using namespace std;
  
  // this replicates my new Data structure
  typedef struct books
  {
     UINT16   book_id;
     UINT16   book_no_of_copies;
     books() : book_id(0), book_no_of_copies(0) {}
  } BOOKS;
  
  void printBook( UINT32 book );
  
  int main( )
  {
      BOOKS Book1;        // Declare Book1 of type BOOKS
      BOOKS Book2;        // Declare Book2 of type BOOKS
  
      // book 1 specification
      Book1.book_id = 11; // initialization
      Book1.book_no_of_copies = 2;
  
      // book 2 specification
      Book2.book_id = 12; // initialization
      Book2.book_no_of_copies = 10;
  
      // pass struct as integer
      // Print Book1 info
      printBook( *(UINT32 *)&amp;Book1 );
  
      // Print Book2 info
      printBook( *(UINT32 *)&amp;Book2 );
      getchar();
      return 0;
  }
  
  void printBook( UINT32 book )
  {
      // re-convert integer to struct
      BOOKS myBook = *(BOOKS *)&amp; book;
      cout &lt;&lt; "Book id : " &lt;&lt; myBook.book_id &lt;&lt;endl;
      cout &lt;&lt; "Book no of copies : " &lt;&lt; myBook.book_no_of_copies &lt;&lt;endl;
  }
  </code></pre>