title: Why struct assignment works with arrays in structs
body: <p>I was attempting to explain to a co worker a concept and came to the realization I was incorrect in my understanding.</p>
  
  <p>How are structs with arrays embedded assignable?</p>
  
  <p>For example:</p>
  
  <pre><code>typedef struct {
      uint8_t data[8];
  } Test;
  ...
  Test test1;
  Test test2;
  ... some assignment to test1
  test2 = test1;
  </code></pre>
  
  <p>I know if data was of type pointer that we would need to implement a deep copy but I'm trying to understand fully the way this works.</p>
  
  <p>My though process is that as 'data' would normally be the pointer to the first element and that &amp;data would be the address of that pointer. In the case of the struct is the struct address what the compiler is using to access the array?</p>
  
  <p>Can someone explain the language mechanism that allows this. Is this just syntactic sugar for c structs? If so, why not implement direct array assignment like so...</p>
  
  <pre><code>uint8_t data[10];
  uint8_t data2[10];
  ...
  data2 = data;
  </code></pre>
  
  <p>Why after years of C programming am I having an existential language crisis about a mechanism I have used but never understood?</p>