Receive 3 char and a integer value via i2c

Hello,

i want to receive 3 chars and a integer value via i2c.
The problem occours at the end of the last char.

Sender:

  int value=1;
  Wire.beginTransmission(8);
  Wire.write("MAG");
  Wire.write(value);
  Wire.endTransmission();

Receiver:

void receiveEvent(int howMany) {
  int cnt=0;
  int value=0;
  char cmd[3];

  while (1 < Wire.available()) { // loop through all but the last
   char c = Wire.read();
   if (cnt<4){
    cmd[cnt]=c;
    cnt++;
   }

 // next an int
  value=Wire.read();


//debug
Serial.println("Wert");  
Serial.println(value);
Serial.println("Befehl");  
Serial.println((const char *)cmd);

The console shows me:
Wert
1
Befehl
MAG BA• µ

But why?
Is there a char 13 at the end? I don’t think so.

Should i use a own seperator like “;” to set the end?

The variable “howMany” shows me 4 bytes.
Three for the “MAG” and one for the int.

Where does the " BA• µ" comes from???

greetings, Andreas

You're treating cmd like a C string, but I don't see where you terminate it

Omg, thats it. I forgot the 0.
Now it works.

Thanks.