dereferencing an array in a struct (in C)
<p>Let's say I have a struct and the following functions:</p>

<p>struct in header file:</p>

<pre><code>typedef struct {
uint8_t length;
uint8_t data[8];
} simple_vector;
</code></pre>

<p>function:</p>

<pre><code>simple_vector* SD_cmd(uint8_t cmd, uint32_t arg, uint8_t crc, uint8_t read_cnt){

simple_vector vector;

//stuff happens and the simple_vector is manipulated

return &amp;vector;
}
</code></pre>

<p>How do I go about accessing the non-zeroth element of an array using the -> operator?</p>

<p>Let's say a function returns a pointer to this struct:</p>

<pre><code>simple_vector *response;
response = SD_cmd(8, 0x000001AA, 0x87, 5);
uint8_t value = response-&gt;data[3];
</code></pre>

<p>The last line in the above snippet does not return the correct value. I've debugged (on an mcu) and verified that the data[3] in the function is not the same as what I get when I dereference it outside of the function. Any thoughts?</p>