If you are using the String library you can use standard array logic to access the pointer rather than toCharArray which copies the entire array.
void setup() {
String data = "123.456";
char * carray = &data[ 0 ];
float f = atof( carray );
Serial.begin( 9600 );
Serial.print( f, 5 );
}
void loop() {}
The alternative using toCharArray works like this: ( carray must be an array, or pointer to valid data )
void setup() {
String data = "123.456";
char carray[ 10 ];
data.toCharArray( carray, 10 );
float f = atof( carray );
Serial.begin( 9600 );
Serial.print( f, 5 );
}
void loop() {}