title: strchr(), How does this correctly find the index of a char
body: <p>I'm looking at the example for strchr() on: <a href="http://www.cplusplus.com/reference/cstring/strchr/" rel="nofollow">http://www.cplusplus.com/reference/cstring/strchr/</a></p>
  
  <p>Why does this correctly find the index? Intuitively it looks like it should be giving a negative index:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  int main ()
  {
    char str[] = "This is a sample string";
    char * pch;
    printf ("Looking for the 's' character in \"%s\"...\n",str);
    pch=strchr(str,'s');
    while (pch!=NULL)
    {
      printf ("found at %d\n",pch-str+1);
      pch=strchr(pch+1,'s');
    }
    return 0;
  }
  </code></pre>