title: How can gets() exceed memory allocated by malloc()?
body: <p>I have a doubt in malloc and realloc function, When I am using the malloc function for
  allocating the memory for the character pointer 10 Bytes. But when I am assigning the value 
  for that character pointer, it takes more than 10 bytes if I try to assign. How it is possible.</p>
  
  <p>For example: </p>
  
  <pre><code>main()
  {
      char *ptr;
      ptr=malloc(10*sizeof(char));
      gets("%s",ptr);
      printf("The String is :%s",ptr);
  }
  </code></pre>
  
  <p>Sample Output:</p>
  
  <pre><code>$./a.out
  hello world this is for testing
  </code></pre>
  
  <p>The String is :hello world this is for testing</p>
  
  <p>Now look at the output the number of characters are more than 10 bytes.
  How this is possible, I need clear explanation.
  Thanks in Advance.</p>