title: Allocating memory in C Function
body: <p>Its memory wastage vs cpu utilization question.</p>
  
  <p>If I want to merge 3 strings:</p>
  
  <ul>
  <li><p>Approach 1: Should I take all string lengths (strlen) and then allocate.</p>
  
  <pre><code>char *s = malloc(strlen(s1)+strlen(s2)+strlen(s3)+1);
  </code></pre></li>
  </ul>
  
  <p>OR</p>
  
  <ul>
  <li><p>Approach 2: I should assume <code>1025</code> and allocate considering the fact that I know the strings will never go beyond 1025.</p>
  
  <pre><code>#define MAX 1025
  char *s = malloc(MAX);
  </code></pre></li>
  </ul>
  
  <p>Please suggest.</p>