C++ double to string pointer

Hi,

I have a C++ code having 2 pointers :

char *strPtr;
double *dblPtr;

These have got to be in the code. I cannot replace them with anything.

I am in the need of copying the value of dblPtr in strPtr.
This is what I am doing -

sprintf(strPtr,"%f", *dblPtr)

This is working fine. If dblPtr's value = 150 then strPtr is set to "150.0000".

I want to know -

1. is there a better way of doing this in C++ ?
2. is there a way to remove ".0000" from strPtr ?

NOTE: I did try %g in the sprintf but it was producing results in exponential.
1) Use a stringstream
2) Use a stringstream/stream manipulators, in C, you can use the printf format specifiers
Thanks firedraco.
For 1 - I understand you are suggesting :

std::ostringstream sstream;
sstream << *dblPtr;

But then how do we copy sstream to my character pointer strPtr ?
Topic archived. No new replies allowed.