hey, how would i go about converting a char* character array to a double.
I would like to create a function that takes a char array as a parameter such as "1234.1" and then return that as a double value 1234.1.

Is there a function that would allow me to do this or would i have to go about programming it myself?

Thanks.

>hey, how would i go about converting a char* character array to a double.
Provided the array is actually a string with a terminating '\0' character at the end, you can use strtod. Or, since this is C++, stringstreams make the conversion intuitive if you're used to cin and cout:

#include <sstream>

double to_double ( const char *p )
{
  std::stringstream ss ( p );
  double result = 0;

  ss>> result;

  return result;
}
commented: Just what I was looking for :D +1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.