title: typecasting bigger or smaller structure in C
body: <p>I have two structures in C program:
  SmallStructABC and BigStructXYZ</p>
  
  <p>I have several members in both of them; 
  SmallStructABC's all 10 members are exactly same as first 10 members of BigStructXYZ.
  BigStructXYZ has 50 additional members.</p>
  
  <p>Is it OK to type-cast this two structures to each other?</p>
  
  <pre><code>SmallStructABC *i = (BigStructXYZ*)j;
  BigStructXYZ   *a = (SmallStructABC*)b; 
  </code></pre>
  
  <p>I only access first 10 (common) members after type-casting..</p>
  
  <p>I wrote C program and its working fine on my machine. Just wanted to verify if I need to take care of any corner cases (alignment, invalid read, non-gcc compilation etc)..</p>
  
  <p>EDIT:
  Q: Why I want to do something like this?</p>
  
  <p>A: BigStructXYZ is very big in size (say 50KB) and contains some header (keys, map etc).
  I compress this data before sending over network. I leave header (in our case its SmallStructABC) as it is. 
  By doing type-cast, I can access these keys from header as and when required. </p>