title: while (*next != NULL) loop not exiting when pointer is NULL
body: <p>Please can someone help me with this problem, the while loop in the following C code doesn't seem to exit when *next == NULL and tries to call strlen(*next) with a bad ptr in Visual Studio 2010 Express. I've tried everything I can think of to no avail. The code tries to find the shortest and longest strings in an array of strings. </p>
  
  <pre><code>char *stringsInArray[] = {"green mats", "cat", "sat", "on", "the", "green mat", NULL};
  char *shortest, *longest, **current, **next, **end;
  
  current = stringsInArray;
  next = stringsInArray + 1;
  shortest = stringsInArray[0];
  longest = stringsInArray[0];
  
  while (*next != NULL) 
  {
      if (strlen(*current) &lt; strlen(*next))
      {
          if (strlen(shortest) &gt; strlen(*next))
              shortest = *next;
          if (strlen(*current) &lt; strlen(shortest))
         shortest = *current;
          if (strlen(*next) &gt; strlen(longest))
              longest = *next;
      }  
      else
      if (strlen(*current) &gt; strlen(*next))
      {
          if (strlen(*current) &gt; strlen(longest))
        longest = *current;
          if (strlen(*next) &lt; strlen(shortest))
        shortest = *next;
      }
      else // strlen(*stringsInArray) == strlen(*next)
      {
          // do nothing
      }
  
     *current++;
     *next++;
  } 
  
  printf("shortest string: %s\n",*shortest);
  printf("longest string: %s\n",*longest);
  </code></pre>