title: memory leak Error in c
body: <p>I have this code</p>
  
  <pre><code>char* chars = (char*) malloc (sizeof(char));
  memcpy(chars, "", 0);
  char* hey = "hello doit";
  chars = (char*) realloc (chars, 10);
  memcpy(chars, hey, 10);
  printf("string: %s\n", chars);
  free(chars);
  </code></pre>
  
  <p>and I'm getting an error in memory</p>
  
  <pre><code>Address "xxxxxxx" is 0 bytes after a block of size 10 alloc'd
  </code></pre>
  
  <p>what am I doing wrong?</p>