# Is there a faster way to clear the screen?

I'm currently clearing my console window with this piece of code:

void clrScr()
{
COORD cMap =
{
0, 3
};
if(!FillConsoleOutputAttribute(hCon, 0, 2030, cMap, &count))
{
std::cout << "Error clearing the console screen." << std::endl;
std::cout << "Error code: " << GetLastError() << std::endl;
std::cin.get();
}
}


, which I call once in the main loop.
But since my window is quite large (70x35), it's flickering quite a bit.

I was wondering if there are any faster methods of doing this?

-
Have a look at ncurses for a platform neutral techniques for clearing a console window. –  Loki Astari Dec 4 '12 at 7:33
Not really looking for a new lib. Thanks anyways. –  user19953 Dec 4 '12 at 9:57
You should be looking for a new lib. You are using standard IO for stuff which it wasn't meant to be used for. –  Winston Ewert Dec 5 '12 at 21:27

Have a look at Clear the Screen. It basically boils down to using what you did (since the Windows console doesn't accept standard ansi sequences), although you might try the conio.h route.

-
I can't use clrscr() for some reason. Probably something to do with the fact that it's non-standard. And pretty much the only other way (without using external libs) would be the way I'm doing it.. It seems there are no better ways of doing this, so I won't accept an answer, at least for now. If there are no better answers after a while, I'll accept yours. –  user19953 Dec 5 '12 at 23:09

system("cls");
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.35249876976013184, "perplexity": 2518.3903519016067}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2014-35/segments/1408500828050.28/warc/CC-MAIN-20140820021348-00169-ip-10-180-136-8.ec2.internal.warc.gz"}