Clearing Screen

Mar 5, 2013 at 1:49pm
Hello all. I am having a problem with my c++ code. I am attempting to clear the text off of the command prompt screen in a text based game program. I put a restart option using a goto in my program. How would I be able to clear all previously displayed text.
Mar 5, 2013 at 1:58pm
use a bunch of newlines, and just move the old output out of sight
Mar 5, 2013 at 4:01pm
Could i see an example of using a newline?
Mar 5, 2013 at 4:31pm
std::cout << std::endl;
Mar 5, 2013 at 5:01pm
how about CMD?

system("cls");
Mar 5, 2013 at 5:05pm
http://www.cplusplus.com/articles/4z18T05o/


In a nutshell:
std::cout << std::string(300, '\n') << std::endl;

Do not use system()!
Last edited on Mar 5, 2013 at 5:06pm
Mar 5, 2013 at 5:10pm
i know system is evil but in his case probably not!
Last edited on Mar 5, 2013 at 5:20pm
Mar 5, 2013 at 5:26pm
When I used
system("cls");
it did not work, however when I added
#include <cstdlib>
it worked perfectly, thanks!
Topic archived. No new replies allowed.