Cut Off Word Overflow in Command Prompt?

Hey guys,
Yesterday one of my friends was creating an RPG program on Command Prompt for one of his classes, and being known as a person who is good with code he asked me a question. "How do I prevent command prompt from cutting off words in word wrap partially through? Ex:
You now find yourself in the Egyptian border. Wh
ere would you like to go?"

I honestly had no idea so I did a bit of research with no real results... He has decided just to submit it because the teacher will still give full credit, but being the inquisitive programmers I am, I still want the answer. It has been bugging me. (Aside from just adding end lines...)

Anyone know the answer to this question?

Merci,
Stevie
Last edited on
\n
If you know the current width of the console, you can split each line into words and keep moving words to a second line if they cause the line length to exceed the limit.
How would you do that exactly Athar?
...
Aramil, how does the \n function within the code?
There is no automatic way to do it. You have to have an idea of how many columns there are (you can safely assume 80). Then, while the text you want to print is >= max cols, find the last space before the max columns, print everything before that plus a newline, and repeat with everything after that.

Hope this helps.
Topic archived. No new replies allowed.