title: Return value of function strlen()?
body: <p>This is the definition of strlen i have goggled up.</p>
  
  <blockquote>
    <p>strlen( ) function counts the number of characters in a given string and returns the integer value. It stops counting the character when null character is found.</p>
  </blockquote>
  
  <p>Now according to me the strlen for "kshitij" should be = 7 i.e not including the null character because the function stops counting as and when it encounters the null character.
  Therefore if I want to print the word "kshitij" and its reverse as many times as the letters in the word, then the correct code should be.</p>
  
  <pre><code>#include&lt;iostream.h&gt;
  #include&lt;stdio.h&gt;
  #include&lt;conio.h&gt;
  #include&lt;string.h&gt;
  int main()
  {
      char a[1000];
      gets(a);
      int len=strlen(a);
      for(int i=0; i&lt;= len ; i++)
      {
          for(int j=len ; j&gt;=0; j--)
          {
              cout&lt;&lt;a[j];
          }
          cout&lt;&lt;" ";
      }
      getch();
       return 0;
   }
  </code></pre>
  
  <p>accordingly it provides the reasonably correct output.(Apart of spacing I don’t understand)</p>
  
  <p><a href="https://i.stack.imgur.com/3BSy4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3BSy4.png" alt="enter image description here"></a></p>
  
  <p>now I was curious to know what would it print if  i did :</p>
  
  <pre><code> #include&lt;iostream.h&gt;
   #include&lt;stdio.h&gt;
   #include&lt;conio.h&gt;
   #include&lt;string.h&gt;
   int main()
   {
      char a[1000];
      gets(a);
      int len=strlen(a);
      for(int i=0; i&lt;= len ; i++)
      {
          for(int j=len -1 ; j&gt;=0; j--)
          {
              cout&lt;&lt;a[j];
          }
          cout&lt;&lt;" ";
      }
      getch();
      return 0;
   }
  </code></pre>
  
  <p>which according to me should not produce the last letter which is "j" but what i see is that it produces the same output but 1 less spacing then before.</p>
  
  <p><a href="https://i.stack.imgur.com/eNIB3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eNIB3.png" alt="enter image description here"></a></p>
  
  <p>similarly i tried :</p>
  
  <pre><code>#include&lt;iostream.h&gt;
  #include&lt;stdio.h&gt;
  #include&lt;conio.h&gt;
  #include&lt;string.h&gt;
  int main()
  {
      char a[1000];
      gets(a);
      int len=strlen(a);
      for(int i=0; i&lt;= len - 1  ; i++)
      {
          for(int j=len ; j&gt;=0; j--)
          {
          cout&lt;&lt;a[j];
          }
          cout&lt;&lt;" ";
      }
      getch();
      return 0;
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/Lj0iw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Lj0iw.png" alt="enter image description here"></a></p>
  
  <p>over here according to me the ouput should contain only " 7 - 1 = 6 " times the reverse string but the ouput almost the same.The -1 has no effect on the value of "len".</p>
  
  <p>With all this on my plate , I feel that the <code>strlen</code> function must count the null character as well, wiz <code>strlen (a)= 8</code> (including <code>‘\0’</code>), but then I see only 7 outputs in the output window.
  This leaves me wondering  if the strlen function counts the null character as well or not, and if it does then it must show it as a space in the output window. I am unable to apprehend the complete concept, any help is appreciated? 
  I am new to programming please take it easy on me. Thanks :).  </p>