title: C - access memory directly using address?
body: <p>I've been lightly studying C for a few weeks now with some book.</p>
  
  <pre><code>int main(void)
  {
      float num = 3.15;
      int *ptr = (int *)&amp;num; //so I can use line 8 and 10
  
      for (int i = 0; i &lt; 32; i++)
      {
          if (!(i % 8) &amp;&amp; (i / 8))
              printf(" ");
          printf("%d", *ptr &gt;&gt; (31 - i) &amp; 1);
      }
  
      return 0;
  }
  </code></pre>
  
  <hr>
  
  <pre><code>output : 01000000 01001001 10011001 10011010
  </code></pre>
  
  <p>As you see <code>3.15</code> in single precision <code>float</code> is <code>01000000 01001001 10011001 10011010</code>.
  So let's say <code>ptr</code> points to address <code>0x1efb40</code>.</p>
  
  <p><strong>Here are the questions:</strong></p>
  
  <ol>
  <li><p>As I understood in the book, first 8 bits of <code>num</code> data is stored in <code>0x1efb40</code>, 2nd 8 bits in <code>0x1efb41</code>, next 8 bits in <code>0x1efb42</code> and last 8 bits in <code>0x1efb43</code>. Am I right?</p></li>
  <li><p>If I'm right, is there any way I can directly access the 2nd 8 bits with hex address value <code>0x1efb41</code>? Thereby can I change the data to something like <code>11111111</code>?</p></li>
  </ol>