simplest way to convert string to float?

I need a little help with this - I have a super simple Problem: I want to read a String from Serial.readln() and convert it to a float. But:floatvariable = atof(stringvariable);Does not work (cannot convert 'String' to 'const char*' for argument '1' to 'double atof(const char*)'). What am I missing? There must be a pretty simple function to do that, but I can't find it :(

first : the usage of String class is not preferred (memory problems) second: try

String s =  ..

float v = atof( s.toCharArray() );

it is on the manual page of the String Class - http://arduino.cc/en/Reference/StringToCharArray -

You'll have to convert it to a string first, which begs the question, why bother using a String at all?

That's what I do:

String inData;                                                                          //Allocate some space for the string
char inChar;
float float_var; 
.
.
.
if(Serial.available() >0){
  int_i=0;
  inData ="";
  while(Serial.available() > 0){
    delay(10);
    inChar = Serial.read();
    inData += inChar;
    int_i++;  
}
   float_var = atof(inData);

if I use float_var = atof(inData.toCharArray()); I get: " no matching function for call to 'String::toCharArray()'"

Reference on how to use the toCharArray() method: http://arduino.cc/en/Reference/StringToCharArray

perfect, thx for the help. For everyone coming here with search function:

String inData;
char char1[8];
float float 1;
.
.
.
inData.toCharArray(char1, inData.length() +1);  
float1 = atof(char1);

works like a charm :)

A similar approach:

Serial.println(readstring);  //so you can see the captured string
    char carray[readstring.length() + 1]; //determine size of the array
    readstring.toCharArray(carray, sizeof(carray)); //put readStringinto an array
    float f = atof(carray); //convert the array into a float