title: Accessing struct members directly
body: <p>I have a testing struct definition as follows:</p>
  
  <pre><code>struct test{
      int a, b, c;
      bool d, e;
      int f;
      long g, h;
  };
  </code></pre>
  
  <p>And somewhere I use it this way:</p>
  
  <pre><code>test* t = new test;   // create the testing struct
  int* ptr = (int*) t;
  ptr[2] = 15;          // directly manipulate the third word
  cout &lt;&lt; t-&gt;c;         // look if it really affected the third integer
  </code></pre>
  
  <p>This works correctly on my Windows - it prints 15 as expected, but is it safe? Can I be really sure the variable is on the spot in memory I want it to be - expecially in case of such combined structs (for example f is on my compiler the fifth word, but it is a sixth variable)?</p>
  
  <p>If not, is there any other way to manipulate struct members directly without actually having struct->member construct in the code?</p>