title: strlen and size of for character arrays
body: <p>I have the following code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  
  int main()
  {
     char p[5];
     char q[]="Hello";
     int i=0;
  
     strcpy(p,"Hello");
     printf("strlen(p)=%d\n",strlen(p));
     printf("sizeof(p)=%d\n",sizeof(p));
     printf("strlen(q)=%d\n",strlen(q));
     printf("sizeof(q)=%d\n",sizeof(q));
     for(i=0;i&lt;6;i++)
     {
        printf("p[%d]=%c\tq[%d]=%c\n",i,p[i],i,q[i]);
     }
     return 0;
  }
  </code></pre>
  
  <p>The output that I get is:</p>
  
  <pre><code>strlen(p)=5
  sizeof(p)=5
  strlen(q)=5
  sizeof(q)=6
  p[0]=H  q[0]=H
  p[1]=e  q[1]=e
  p[2]=l  q[2]=l
  p[3]=l  q[3]=l
  p[4]=o  q[4]=o
  p[5]=   q[5]=
  </code></pre>
  
  <ol>
  <li>I know declaring array like q[]="some string" sets the size of the array equal to the number of characters in the string const, but why is there a difference in the output of sizeof() for both the types of array declaration?</li>
  <li>How does the strlen() &amp; the printf() know when to stop, there was no null character added while declaring the two arrays.</li>
  </ol>