How can I clear console using C++?

We can clear the console using C++ code. To do this we have to execute some system commands. In Linux systems, the POSIX is used. We can call system() function to execute system command. For clearing the console in linux, we can use “clear” command. This will be passed inside the system() function.

Let us see the code to get the better idea.


#include <iostream>
using namespace std;
int main () {
   cout << "Now the screen will be cleared!" << endl;
   cout << "Empty Screen" << endl;
   return 0;



karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know