
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
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.
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
- Related Articles
- How to clear console in C?
- How to clear console in MongoDB?
- How can I clear text of a textbox using Python Selenium WebDriver?
- How to Clear the JavaScript Console in Google Chrome
- How can I clear or empty a StringBuilder in Java.
- How do I print Unicode characters in the console using JavaScript?
- How can I get pyplot images to show on a console app? (Matplotlib)
- How do I print a message to the error console using JavaScript?
- How can I check how much time MySQL query, without printing it on the console, is taking?
- How I can use a database-name with special characters like " customer_tracker-990" in MongoDB console
- How do I clear the usage of setInterval()?
- How to clear screen using python?
- How to clear screen using C#?
- How to clear screen using Java?
- How do I clear the cin buffer in C++?

Advertisements