String inputString = "Hello, World!\r"; // Input string with a newline character
String modifiedString = ""; // String to store the modified result
void setup() {
Serial.begin(9600);
// Remove the last character (newline) from the input string
if (inputString.endsWith("\r")) {
modifiedString = inputString.substring(0, inputString.length() - 1);
} else {
modifiedString = inputString;
}
// Print the modified string
Serial.print("Original String: ");
Serial.print(inputString);
Serial.print("\t Text length:");
Serial.println(inputString.length());
Serial.print("Modified String: ");
Serial.print(modifiedString);
Serial.print("\t Text length:");
Serial.println(modifiedString.length());
}
void loop() {
// Your main loop code here
}