English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

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.

2006-09-19 15:37:09 · 2 answers · asked by Harb Frame 3 in Computers & Internet Programming & Design

2 answers

given that your variable is named Amt

Amt.erase(1,1);

2006-09-19 15:46:44 · answer #1 · answered by Jin Tao 3 · 0 0

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.

2006-09-19 17:17:15 · answer #2 · answered by xaxxon44 2 · 1 0

fedest.com, questions and answers