user11784: 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

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

user12054: 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);


11784: <p>How do I split a string into two based on it's length to display on a 2x16 LCD?</p>

<p>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?</p>

<p>Thanks</p>
 368: <p>That's what <a href="https://www.arduino.cc/en/Reference/StringSubstring" rel="nofollow"><code>String::substring()</code></a> is for. Simply take the first 16 characters and the characters from 16 to 32, and output them.</p>
 12054: <p>String::Substring does take a start and an end value. So you can do something like this:</p>

<pre><code>String s1 = longtext.substring(0,15);
String s2 = longtext.substring(16,31);
</code></pre>
