How to remove leading Zeros??

How do I remove the leading zeros during output. I have tried google, but the results I found always have to do with strings. I am using doubles to calculate my answer. Is there a member function of cout (setf, precision, etc..) that removes leading zeros. And by leading zeros I mean:

Leading Zeros : 0.53

I want the output to be .53
What about this?

1
2
3
4
5
6
7
8
string xtos(double x){
 stringstream ss;
 ss << x;
 string s = ss.str();
 if (s.size() && s[0] == '0')
   s.erase(0, 1);
 return s;
}

Last edited on
Topic archived. No new replies allowed.