Skip to main content
added 44 characters in body
Source Link
Juraj
  • 18.2k
  • 4
  • 30
  • 49

byte and char are the same. If you set 0 as string terminator after last character in the buffer, you get a zero terminated string. If you really must use String, you can create an instance with a constructor that takes zero terminated string.

buffer[tam] = 0;
String str((char*) buffer);

(let Let in the buffer a place for the zero). (char*) is cast that says that the byte array is a char array.

Note: Don't use String class in a MCU, use zero terminated character arrays.

byte and char are the same. If you set 0 as string terminator after last character in the buffer, you get a zero terminated string. If you really must use String, you can create an instance with a constructor that takes zero terminated string.

buffer[tam] = 0;
String str((char*) buffer);

(let in the buffer a place for the zero)

Note: Don't use String class in a MCU, use zero terminated character arrays.

byte and char are the same. If you set 0 as string terminator after last character in the buffer, you get a zero terminated string. If you really must use String, you can create an instance with a constructor that takes zero terminated string.

buffer[tam] = 0;
String str((char*) buffer);

Let in the buffer a place for the zero. (char*) is cast that says that the byte array is a char array.

Note: Don't use String class in a MCU, use zero terminated character arrays.

added 44 characters in body
Source Link
Juraj
  • 18.2k
  • 4
  • 30
  • 49

byte and char are the same. If you set 0 as string terminator after last character in the buffer, you get a zero terminated string. If you really must use String, you can create an instance with a constructor that takes zero terminated string.

buffer[tam] = 0;
String str((char*) buffer);

(let in the buffer a place for the zero)

Note: Don't use String class in a MCU, use zero terminated character arrays.

If you set 0 as string terminator after last character in the buffer, you get a zero terminated string. If you really must use String, you can create an instance with a constructor that takes zero terminated string.

buffer[tam] = 0;
String str(buffer);

Note: Don't use String class in a MCU, use zero terminated character arrays.

byte and char are the same. If you set 0 as string terminator after last character in the buffer, you get a zero terminated string. If you really must use String, you can create an instance with a constructor that takes zero terminated string.

buffer[tam] = 0;
String str((char*) buffer);

(let in the buffer a place for the zero)

Note: Don't use String class in a MCU, use zero terminated character arrays.

Source Link
Juraj
  • 18.2k
  • 4
  • 30
  • 49

If you set 0 as string terminator after last character in the buffer, you get a zero terminated string. If you really must use String, you can create an instance with a constructor that takes zero terminated string.

buffer[tam] = 0;
String str(buffer);

Note: Don't use String class in a MCU, use zero terminated character arrays.