Function To Convert string To double

Hi,
I am writing a form application in VC++.
At one place I have to convert string into double.I tried strtod() function by including stdlib.h in .cpp file.(my code is in Form1.h file).but is giving me compilation error i.e. strtod:identifier not found.

Any suggestions so that I can convert string to double.
I don't understand why you must convert the data, but you could write your own function that does it for you:

double str_to_dub(string str)

Again, I really don't understand why you need to do this.
You could use a stringstream (#include <sstream>).

1
2
3
4
5
6
double StrToDbl(string s) {
     double d;
     stringstream ss(s); //turn the string into a stream
     ss >> d; //convert
     return d;
}

just add a little error-checking...
Topic archived. No new replies allowed.