Computer Science Canada [Console] How do I return to a previous line? |
Author: | Cancer Sol [ Mon Apr 29, 2013 8:52 pm ] | ||||||
Post subject: | [Console] How do I return to a previous line? | ||||||
I've tried to look up all the different ways to return to a previous line, and don't tell me to use a loop because that's not what I need. I'm trying make a delete/erase line function, and I've tried doing this before:
But it didn't work out like I thought it would, unfortunately. So how can I do something like this? Also, kinda a newb question, but, should I code like this:
Or this:
I do the first way because it just looks easier to read, but it's just my opinion. Is it better to the second way because it's shortened? |
Author: | Insectoid [ Tue Apr 30, 2013 5:06 am ] |
Post subject: | RE:[Console] How do I return to a previous line? |
As for your first question, you can't. Not without using complicated platform-dependant libraries that you certainly aren't ready for. And for your second question, do whichever you prefer. Doesn't really matter. |
Author: | DemonWasp [ Tue Apr 30, 2013 5:19 am ] | ||||
Post subject: | RE:[Console] How do I return to a previous line? | ||||
Insectoid is right about your first question. For your second, I would suggest:
Or:
The latter will force the 'cout' stream to flush every time 'endl' is appended. Although you can string together the stream operator like you have in that example, I generally prefer one statement per line (especially in C++, where compilers and IDEs aren't great at telling you the exact location of syntax errors). |
Author: | Cancer Sol [ Tue Apr 30, 2013 11:38 am ] |
Post subject: | Re: [Console] How do I return to a previous line? |
Thanks guys. For my console application, I think I'll just stick with clearing the screen for now, even if it makes flashes I don't like. |