title: garbage value when using malloc
body: <p>I have to compare few characters of string say from 2nd char till 4th character( counting starts from zero)<br>
  The string is stored in elements of structure say zoopla->real<br>
  for example zoopla ->real has '447889036' where real is of type char real[20];<br>
    Also please note I cant use function strnstr.    </p>
  
  <p>The code works as expected but just for curiousity, I have added printf statement and it shows me value till 4th cahr and then some garabe characters.<br>
  I want to know why the printf statment is showing 2 extra garabe values?   </p>
  
  <pre><code>char * copyTemp;                   
  char *strptr;           
  copyTemp = (char *)malloc(sizeof(char)*6);           
  
  strncpy(copyTemp, zoopla-&gt;real, 5);              
  printf("the string copied is %s", copyTemp); // debug statemnt            
  strptr = strstr(copyTemp, "666");           
  
  if(strptr != NULL)              
  {         
  //some other function        
  }        
  else        
  //some other function             
  free(copyTemp);               
  </code></pre>
  
  <p>All criticism and suggestions are welcome</p>