how to clear the output console in code blocks?? why doesn't clrscr(); work in Code::Blocks but works in Borland??
I have already tried:
cout << "\x1b[2J\x1b[1;1H" << flush;
cls() ;
The easiest most straightforward way is to just do it through system
function call:
#include <stdlib.h>
int main()
{
system("cls");
}
If you want to do it programmatically MSDN shows how here.
Note that there is no standard function provided by C++ for clearing the console. Some compilers, like borland, provides it as a non-standard function for convenience but it's not portable between different compilers.
You can use the OS commands to clear the contents of the console.
#include<stdlib.h>
int main(){
system("cls"); //For windows
system("clear"); //For Linux
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With