2019-08-19, 09:18 PM
(2019-08-19, 05:38 AM)Y_Less Wrote: While using spaces is not at all a unique way of splitting strings, it's a good effort. However, there are many ways it can be improved. You don't need to copy the strings around at all, simply inserting a null character will end a string so you can send part, then put the original character back. This method is infinitely extendable so you aren't limited to 2 lines only.
You've also not considered what happens if someone types a very long line with no spaces. Most systems will also opt to split mid word if it is a long word and the lines would otherwise be extremely unbalanced.
Thanks, didn't know that actually. But my goal was breaking in max TWO lines, because of aestethics, and I didn't want to pile up my chatbox more than it is
I've considered second option - if broken bool stays false after the loop, it sends the line as it is, unbroken. That's why it seeks space from 60th char, and it breaks after 90, just so it can find "optimal" space for breaking. Neary?any word exists that?has more than 30 chars in one piece without space, so I've used that to break.