Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

1 Answer
karthikeya Boyini

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.

Example

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

Output

After

Advertisements

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.