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?
Thanks
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– Josh2015年08月28日 09:54:51 +00:00Commented Aug 28, 2015 at 9:54
-
1Use it as many times as you need in order to get all desired substrings.Ignacio Vazquez-Abrams– Ignacio Vazquez-Abrams2015年08月28日 09:55:33 +00:00Commented Aug 28, 2015 at 9:55