Estimating length of result of sprintf
<p>I need to estimate the length of the string obtained on  <code>sprintf</code> operation. How can I do this. In other words, how can I avoid harcoding the value <code>50</code> in the below snippet.</p>

<pre><code>double sum;
char* resultString;
..

resultString = new char[50]; //how can I avoid hardcoding 50 here?
sprintf(resultString,"[%e]",sum);
</code></pre>
