I need to estimate the length of the string obtained on `sprintf` operation. How can I do this. In other words, how can I avoid harcoding the value `50` in the below snippet.

```
double sum;
char* resultString;
..

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

```