title: Dynamic memory resize char array
body: <p>I'm trying resize a char array, i've followed:
  <a href="https://stackoverflow.com/questions/1354900/resizing-a-char-at-run-time">Resizing a char[] at run time</a></p>
  
  <p>then:</p>
  
  <p>i've done something like this:</p>
  
  <pre><code>// this crashes in runtime:
  
  const long SIZE_X = 1048576;
  
  char* Buffsz = new char(sizeof(char));
  
  for(int i = 0; i &lt; (SIZE_X - 2); i++)
  {
      Buffsz[i] = 'a';
      if(realloc(Buffsz, sizeof(char) * i) == NULL) // autoallocate memory
          cout &lt;&lt; "Failled to reallocate memory!" &lt;&lt; endl;
  }
  </code></pre>
  
  <p>but if I do:</p>
  
  <pre><code>// this works without problems.
  const long SIZE_X = 1048576;
  
  char* ABuffsz = new char[SIZE_X];
  
  for(int i = 0; i &lt; (SIZE_X - 2); i++)
  {
      ABuffsz[i] = 'a';
  }
  
  cout &lt;&lt; "End success! len: " &lt;&lt; strlen(ABuffsz) &lt;&lt; endl;
  </code></pre>
  
  <p>For me this should be fine, but if it's wrong, how i can auto allocate memory?</p>
  
  <p>P.S: I know about of use <code>std::vector</code> but i want use this if its possible.</p>