string to character and reverse

hiii every budy ... im having lettle problem with my xbee's /// cant send and receive float numbers /// im trying to send them as characters but cant convert them back to float number ... here is my tx and rx code:
//TX
void setup()
{
Serial.begin(9600);
}
void loop()
{
float d=50.1;
Serial.print(String('50.1'));
delay(3000);
}
And my RX :
//RX
void setup()
{
Serial.begin(9600);
}
String h[20];
void loop()
{
int i=0;
float d;
while(Serial.available()==0);
for(i=0;i<=20;i++)
{
h*=Serial.read()-'0';*

  • delay(100);*

  • }*

  • for(int j=0;j<=20;j++)*

  • {*

  • Serial.print(h[j]);*

  • delay(3000);*

  • }*
    }

  Serial.print(String('50.1'));

'50.1' is valid C syntax, to define a multi-byte character. It is highly unlikely that this is what you want to do (or think you are doing. Try:

  Serial.print(String("50.1"));
  h=Serial.read()-'0';

So, when the '.' arrives, what is '.' - '0'?

This block of code will be executed as soon as there is at least one byte to read.

 for(i=0;i<=20;i++)
  {
  h=Serial.read()-'0';
  delay(100);
  }

Reading 20 of the 1 bytes available is generally not a good idea.

You need to change your sender to use start- and end-of-packet markers. Then, you need to change the receiver to make use of those markers. This has been discussed on this forum many, many times.