clrscr(); equivalent in Code::Blocks
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.
This is actually a quite simple problem. All you have to do is use printf. You don't even need printf or any headers, for that matter.
printf("\e[1;1H\e[2J");
The \e[1;1H sets the screen to the 1st row and 1st column. the 2J overwrites all characters currently on the screen.
You can also use this:
write(0,"\e[1;1H\e[2J",12);
Then you don't need stdio.h.
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
}