title: Using realloc (X, 0) instead of free() and using malloc with length of a string +1
body: <p>So I don't really know how to put the title this time. First of all I'd like to say that I've seen several comments on this page about warning if the question is related to "homework".
  Mine is, but it's also completed and I just want to further understand what is going on with the code.</p>
  
  <p>I have also read posts and books for some time, but I think I am still missing things.</p>
  
  <p>I have 2 lines of code I don't quite understand in the code I worked with. The work is about getting whatever file is used as argument (if it's 0 files, it read from stdin), and print it on the standard output backwards. All of this, talking about C as I tried to put in the tag. </p>
  
  <p>First problem is this:</p>
  
  <pre><code>array = realloc (array, 0);
  </code></pre>
  
  <p>Where array is defined as</p>
  
  <pre><code>char **array;
  </code></pre>
  
  <p>And the problem is that free doesn't work, it does not free the space used (maybe I used it wrong? In other place I have known how to use it, but not this time). With the testing I have done and what I have read, I believe that realloc is doing the same, but I'm no 100%.</p>
  
  <p>Second one is:</p>
  
  <pre><code>char* alloc = malloc (strlen ((char*)string)+1);
  </code></pre>
  
  <p>Where alloc is used to copy the exact length of the line I am going to put into an array, so I can, after that, just print the text backwards.</p>
  
  <p>And the question is why I have to use that +1. I mean if I don't use for some reason it doesn't work, I tried with different numbers and it works everytime, but if I don't do that +1 it does not work correctly.</p>
  
  <p>I know probably the question is too vague and bad written to really be answered but again, I'm not sure about that and I did my best to explain myself (english no mother tongue as it's probably obvious).</p>