title: Can a pointer be volatile?
body: <p>Consider the following code:</p>
  
  <pre><code>int square(volatile int *p)
  {
      return *p * *p;
  }
  </code></pre>
  
  <p>Now, the <code>volatile</code> keyword indicates that the value in a
  memory location can be altered in ways unknown to the compiler or have
  other unknown side effects (e.g. modification via a signal interrupt,
  hardware register, or memory mapped I/O) even though nothing in the
  program code modifies the contents.</p>
  
  <p>So what exactly happens when we declare a pointer as volatile?</p>
  
  <p>Will the above mentioned code always work, or is it any different from this:</p>
  
  <pre><code>int square(volatile int *p)
  {
      int a = *p;
      int b = *p
      return a*b;
  }
  </code></pre>
  
  <p>Can we end up multiplying different numbers, as pointers are volatile?</p>
  
  <p>Or is there better way to do so?</p>