Xbee string processing

hi there, i have some problem with Xbee string processing here. i am transmitting data (Z7180888320) from xbee A, for some reason there is "Z" on beginning of the string, there is list of program that i use to re-create the string on arduino Xbee B:

int val; int buff; void setup () { Serial.begin(9600); }

void loop () { if(Serial.available()) val = Serial.read(); if(val == 'Z') { String received = ""; while(Serial.available() == 0) { } int x = Serial.read(); char y = (char) x; received = received + y; Serial.print (received); if (received == "7180888320") { Serial.print ("Match!"); } buff++; if(buff == 10) { buff = 0; val = 0; String received=""; Serial.println (); } } }

the problem is if i look on the output serial monitor, the 7180888320 appear but word "Match!" didn't. is there any way to re-create string from xbee and compare it with another string? sorry for my bad english

      String received = "";
      while(Serial.available() == 0)
      {
      }
      int x = Serial.read();
      char y = (char) x;
      received = received + y;
      Serial.print (received);
      if (received == "7180888320")
      {
        Serial.print ("Match!");
      }

You blank the String before before you read a single character and expect it to equal a 10 character string. Why? You should be reading ever character, and stuffing it into an array until you reach some defined deliminating character. At that point, you can compare the value to a constant.

Arrch: You blank the String before before you read a single character and expect it to equal a 10 character string. Why? You should be reading ever character, and stuffing it into an array until you reach some defined deliminating character. At that point, you can compare the value to a constant.

thank you for the advice , I tried using char array for reading serial communication

inChar = Serial.read();
      inData[index] = inChar;
      index++;
      if (index == 10)
      { 
        inData[index] = '\0';
        Serial.print (inData);
        if(strcmp(inData,str) == 0)
        {//insert command//}

best regards, Tadakuni

So did it work? If not, post ALL of your code, and explain how it didn't work.