Skip to content

String not changeable (only ARDUINO DUE) #2964

@MichaDi

Description

@MichaDi

The following code compiled for an ARDUINO DUE leads to a different result than the code compiled for AVR-based ARDUINOS (IDE-Version: 1.6.3):

void setup() {
  Serial.begin(115200);
}
void loop() {
  printOnDisplay("This is a test");
  while(1);
}
void printOnDisplay(char *string)
{
  string[4] = 0;
  Serial.println(string);
  if (string[4]) Serial.println("String hasn't changed!");
  else Serial.println("String has changed!");
}

On an ARDUINO DUE the serial output is:
"This is a test"
"String hasn't changed!"

On AVR-based ARDUINOS the output is:
"This"
"String has changed!"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions