title: how does following program work pointer manipulation
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/4989416/a-c-program-from-gate-paper">A c program from GATE paper</a>  </p>
  </blockquote>
  
  
  
  <p>Here is a program which is working</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  int main ()
  {
  char c[]="GATE2011";
  char *p=c;
  printf("%s",p+p[3]-p[1]);
  }
  </code></pre>
  
  <p>The output is </p>
  
  <pre><code>2011
  </code></pre>
  
  <p>Now comes the problem I am not able to understand the operation p+p[3]-p[1]
  what is that pointing to?</p>
  
  <p>My understanding is when I declare some thing like</p>
  
  <pre><code>char c[]="GATE2011"
  </code></pre>
  
  <p>Then c is a pointer pointing to a string constant and the string begins with G.
  In next line <code>*p=c;</code>
  the pointer p is pointing to same address which c is pointing.
  So how does the above arithmetic work?</p>