How do I split a string into two based on it's length to display on a 2x16 LCD?

I have seen a function called length() to get the length of a string. But, any ideas how to split it in to 2x16 and trim the rest of the string?


2 Answers 2


String::Substring does take a start and an end value. So you can do something like this:

String s1 = longtext.substring(0,15);
String s2 = longtext.substring(16,31);

That's what String::substring() is for. Simply take the first 16 characters and the characters from 16 to 32, and output them.

  • But,what about the rest of the string? I need 2 x 16 of the 32. Substring only provides one part right?
    – Josh
    Commented Aug 28, 2015 at 9:54
  • 1
    Use it as many times as you need in order to get all desired substrings. Commented Aug 28, 2015 at 9:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.