I am working on a small project where i am inputting a string then outputing that same string within a box, where the string is wrapped to fit in that box.
A pointer to the string is passed to the function.
What i have at the min is a for loop indexing the string, I then check for a 'space', when the space is found i copy into another string, the original string upto x places(where the space is found). If the str is longer than the box is wide i need to wrap only on a space. So at the mo, i have the first line in a temp string (this is fine prints to the screen ok). So i now move to line two where i save the location of the space with a pointer, so i now print line two from the pointer. This is also fine, what i cant seem to do is print the middle of the string (if say the string goes over 2 lines). e.g. How do i save from point 10 to point 20 in the string?
When i keep updating the space pointer, it will not print anything before the space so i loose words if max width is not true.
What i thought i may be able to do is use an array of pointers, with each pointing to one line? But i am not convinced that will do the trick.
Maybe you guys will have some ideas, and give me a few pointers on how i should go about doing this.
Thanks in advance.