title: Character array in C(Puts vs printf)
body: <p>I have some doubts regarding character array in C, I have a character array of size 1, logic says that when I input more than 2 characters, I should be getting a segmentation fault, However <code>puts</code> prints out the array properly whereas <code>printf</code> prints some parts of the array along with garbage value, Why is this happening</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  int main()
  {
  int i;
  char A[1];
  printf("%d\n",(int)sizeof(A));
  gets(A);
  puts(A);
  for(i=0;i&lt;8;i++)
  {
  printf("%c\n",A[i]);
  }
  }
  </code></pre>
  
  <p>O/P:</p>
  
  <pre><code>1
  abcdefg
  abcdefg
  a
  
  
  
  
  f
  g
  </code></pre>
  
  <p>To add to this I have to type in multiple characters of the <code>array size</code> in the program to throw a segmentation fault. Is it because of the SFP in the stack? The size of SFP is 4 bytes Please correct me if I'm wrong</p>
  
  <pre><code>1
  abcdefghijklmnop
  abcdefghijklmnop
  a
  
  
  
  
  f
  g
  h
  Segmentation fault
  </code></pre>