This function takes a string and an output buffer and a desired width. It then copies the string to the buffer, inserting a new line character when a certain line length is reached. If the end of the line is in the middle of a word, it will backtrack along the string until white space is found.
This code snippet is created originally by Sean Hubbard , I simply am sharing what I learned. I thought it would be best to share his example. Mine is a bit too confusing to understand... his is a lot easier, trust me.