title: Structure and array declaration on same memory location
body: <p>I am working on one Embedded C project. I am having trouble understanding the use of array and structure in code.</p>
  
  <p>for example:</p>
  
  <p><strong>Structure:</strong></p>
  
  <pre><code>struct example_struct{
   char a;
   char b;
   char array[4];
  
  }  
  </code></pre>
  
  <p>Note: The default size for Int and char is 1 byte.</p>
  
  <p>The compiler I am using provide the functionality of memory allocation for variables and other parameters using '@' symbol</p>
  
  <p>for example:</p>
  
  <p><strong>Memory Allocation</strong></p>
  
  <pre><code>int example @ 0x125
  // Compiler allocate the RAM memory location 0x125 to my variable "example"  
  </code></pre>
  
  <p><strong>Issue:</strong> </p>
  
  <p>The person who coded this project have used the structure and array as given below</p>
  
  <p><strong>example.h</strong></p>
  
  <pre><code>struct example_struct{
  char a;
  char b;
  char array[4];
  }  
  </code></pre>
  
  <p><strong>Memory.h</strong></p>
  
  <pre><code>volatile struct example_struct node @ 0x130 ;
  //allocate memory location 0x130 - 0x135 to node  
  volatile char buffer[6] @ 0x130;
  //allocate memory location 0x130 - 0x135 to buffer 
  </code></pre>
  
  <p><strong>Question</strong></p>
  
  <p>1.Instead of using the pointer to access the member of structure is it appropriate to use the array placed on same memory location?</p>
  
  <ol start="2">
  <li>Does it cause the memory issue? </li>
  </ol>
  
  <p>Would you please help me to understand the use of stuct and array in this particular situation. </p>
  
  <p>Thank you</p>
  
  <p>Kunal</p>