I'm not quite sure how to do this, but I want to convert "$63.50" in a string to "63.50" in a double. How would I go about doing this in C++? Thanks.
How do I convert a string (with a dollar sign) to a double in C++?
given that your variable is named Amt
Amt.erase(1,1);
Reply:first, strip the dollar sign, then convert it to a float.
Personally, I'd say:
double var = atof ( mystring.c_str () + 1 );
That's rather C-ish, but it will work.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment