Hello, is there any way to output a string to previous line with std::cout ?
The output would look like:
Line which I wrote second
Line which I wrote first
or, alternately any function, that clears the whole console screen?
Hello, is there any way to output a string to previous line with std::cout ?
The output would look like:
Line which I wrote second
Line which I wrote first
or, alternately any function, that clears the whole console screen?
Last edited by Garland; 08-08-2007 at 06:18 AM. Reason: Wrong tag
Cheap and dirty way include cstdlib (I think), and use:
system("cls");
Alternatively read the faq
It is not possible with std::cout I think. "cls" clears the screen.
Learn C++ (C++ Books, C Books, FAQ, Forum Search)
Code painter latest version on sourceforge DOWNLOAD NOW!
Download FSB Data Integrity Tester.
Siavosh K C
Ok, thank you both, though I think throwing the monitor out of windows is one of the fastest and most reliable solutions, as they say.
You can send all sorts of ANSI escape-codes to the console window under Windows - it may not be as easy as doing "system("cls");", but it's more efficient and you can do more things than just clear the screen (such as move the cursor or erase to end of line and so on)
See: http://en.wikipedia.org/wiki/ANSI_escape_code
--
Mats
Generally if you are writing a program that is supposed to have full controll over console, you should use OS APIs, you can use #ifdefs to make your program portable. With std::cout you can go forward, but can't come back. It is like posting a letter. You can post as many letters as you want to any destination, but you can't bring them back at any time you want!
Learn C++ (C++ Books, C Books, FAQ, Forum Search)
Code painter latest version on sourceforge DOWNLOAD NOW!
Download FSB Data Integrity Tester.
Siavosh K C
Two options I can think of.
1) Use Win32 API console routines to set the cursor position and do other stuff (anything with the console you can do)
2) Use linux ncurses (or a windows port of the library) and do the same thing.
One is portable, one is not. If yer on a windows box of course you wont have to install ncurses library to use the API just read up on MSDN.
Thanks all for your time and help, although by now, you must have probably forgotten, that you even provided it.