dcs-bios / dcs-bios-arduino-library

Arduino Library to talk to DCS-BIOS
MIT License
61 stars 29 forks source link

StringBuffer - is it null terminated? #11

Closed OlHall closed 9 years ago

OlHall commented 9 years ago

Is the string buffer null terminated?

In the example below, the declared string is 4 characters, but does the pointer to newValue point to a 5 char buffer (i.e. 4 data + \0)?

void onRaltDisplayChange(char* newValue) {
    /* your code here */
}
DcsBios::StringBuffer<4> raltDisplayBuffer(0x14aa, onRaltDisplayChange);
jboecker commented 9 years ago

The data we get from DCS-BIOS is not null-terminated, but the StringBuffer class allocates one byte more and adds a null terminator so you can just pass newValue to functions that want a string, such as lcd.print().

OlHall commented 9 years ago

Thanks!