title: Why code is being executed in such strange sequence in c?
body: <pre><code>int is_valid(char *input)
  {
      int i;
  
      for (i = 0;; i++)
      {
          // Check for null terminator
          if ( ! input[i])
          {
              printf("stop executing is_valid()");
              return 0;
          }
  
          // Will be executed for null terminator... o_O
          printf("%c isdigit: %d\n", input[i], isdigit(input[i]));
      }
  
      return 1;
  }
  
  int main()
  {
      char input[80];
      fgets(input, sizeof(input), stdin);
      is_valid(input);
      return 0;
  }
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>1 isdigit: 1
  0 isdigit: 1
  1 isdigit: 1
  
   isdigit: 0 // Why is that here? null terminator after return?!
  stop executing is_valid()invalid input!
  </code></pre>
  
  <p>Why null terminator is processed via <code>isdigit</code> before return? And.. ok, why if condition is executed after it?</p>