title: How to Pointer Output in Programs?
body: <p>In a quiz today, we got this as our question2.</p>
  
  <p>After seeing this, most of us believe that we will fail quite badly.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main ( ) {
    char str[] = "StanfordIsGreat";
  
    char *ptr = str;
  
    printf("%s", ptr);
    printf("%s", ptr + 8);
    printf("%s", ptr + 'l' - 'b');
    printf("%s", ptr + 'k' - ptr[3]);
  }
  </code></pre>
  
  <p>So can anyone guide me answer this question?</p>
  
  <p>what i applied for 1st printf was that the actual string will be printed <code>StanfordIsGreat</code></p>
  
  <p>for 2nd printf, i think the pointer will shift 8 indexes to the right generating <code>IsGreat</code></p>
  
  <p>for 3rd printf, ptr + 'l' gave me <code>StanfordIsGreatl</code>, i didn't understand what <code> - 'b' </code> meant</p>
  
  <p>for 4rth printf ptr + 'k' was same as above and ptr[3] stands for 'a' so i wrote <code>StnfordisGretk</code></p>
  
  <p>i am really confused about 3rd and 4rth, can someone guide me, so i can learn and not make mistakes like this for future quizes.</p>