Send variable using xbee

Hi all,
I’m trying to send variable from urduino uno to xbee through serial monitor to X-CTU. my variable hold integer number as x= 5; I tried the following code but it didn’t work.

#include <SoftwareSerial.h>
SoftwareSerial XBee(4, 5); // RX, TX
int x = 5;
void setup()
{
XBee.begin(57600);
Serial.begin(57600);
}

void loop()
{
XBee.write(x);

}

Thanks in advance

Send variable using xbee

Does that really make sense? Sending the value stored in a variable is not the same thing, but does make sense.

The Serial.write() method sends the value in a byte, as binary data.

You are wrong to claim that "it didn't work". The function sent one of the bytes in the integer. But, which one?

Don't guess. Use the appropriate data type if you are planning to send binary data, or learn how to send multiple bytes of a multi-byte variable.

What is receiving that data? What are you using to back the (invalid) assertion that "it didn't work"?