What exactly does the C Structure Dot Operator Do (Lower Level Perspective)?
<p>I have a question regarding structs in C. So when you create a struct, you are essentially defining the framework of a block of memory. Thus when you create an instance of a struct, you are creating a block of memory such that it is capable of holding a certain number of elements.</p>

<p>However, I'm somewhat confused on what the dot operator is doing. If I have a <code>struct Car</code> and have a member called <code>GasMileage</code> (which is an <code>int</code> member), I am able to get the value of <code>GasMileage</code> by doing something like, </p>

<pre><code>int x = CarInstance.GasMileage;
</code></pre>

<p>However, I'm confused as to what is actually happening with this dot operator. Does the dot operator simply act as an offset from the base address? And how exactly is it able to deduce that it is an int?</p>

<p>I guess I'm curious as to what is going on behind the scenes. Would it be possible to reference <code>GasMileage</code> by doing something else? Such as</p>

<pre><code>int *GasMileagePointer = (&amp;carInstance + offsetInBytes(GasMileage));
int x = *GasMileage
</code></pre>

<p>This is just something i quickly made up. I've tried hard searching for an good explanation, but nothing seems to explain it any further than treating the dot operator as magic. </p>