title: Returning a pointer to a struct
body: <p>I came across a example returning a struct in 'C Programming Language' by Kernighan &amp; Ritchie.</p>
  
  <pre><code>/* binsearch: find word in tab[0]...tab[n-1] */
  struct key *binsearch(char *word, struct key *tab, int n)
  {
      int cond;
      struct key *low = &amp;tab[0];
      struct key *high = &amp;tab[n];
      struct key *mid;
  
      while (low &lt; high) {
          mid = low + (high-low) / 2;
          if ((cond = strcmp(word, mid-&gt;word)) &lt; 0)
              high = mid;
          else if (cond &gt; 0)
              low = mid + 1;
          else
              return mid;
      }
  
      return NULL;
  }
  </code></pre>
  
  <p>It seems that the function is returning a pointer to a local var in the function; wouldn't this be a case of returning a dangling pointer?</p>