Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clear Screen Command in C++

I want to clear the screen after user enters some numbers in C++. I'm programming in console application mode.

so how to do it? My OS is win7 and My IDE is CodeBlocks and the Compiler is MingW...

like image 280
Inside Man Avatar asked Dec 04 '22 17:12

Inside Man


2 Answers

It depends of your OS, If you use linux:

system("clear");

If you use windows:

system("cls"); 

but this make your application lees portable, it's preferable to do

cout << string(50, '\n');

this line will print lines to seem like the terminal was 'cleared'.

A good article about that problem: http://www.cplusplus.com/articles/4z18T05o/

like image 152
Mentezza Avatar answered Dec 09 '22 14:12

Mentezza


You can use the clrscr() defined in conio.h.

Ways to clear screen the output screen.

like image 25
Rohit Vipin Mathews Avatar answered Dec 09 '22 15:12

Rohit Vipin Mathews