Clrscr (); equivalent in Code :: Blocks

how to clear output console in code blocks? why not clrscr (); work in Code :: Blocks, but works in Borland ??

I already tried:

cout << "\x1b[2J\x1b[1;1H" << flush; cls() ; 
+6
source share
10 answers

The easiest easiest way is to simply do this through a call to the system function:

 #include <stdlib.h> int main() { system("cls"); } 

If you want to do this programmatically, MSDN displays as here .

Please note that there is no standard feature provided by C ++ for cleaning the console. Some compilers, such as borland, provide it as a non-standard function for convenience, but do not port between different compilers.

+7
source

This is actually a pretty 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"); 

\ e [1; 1H sets the screen to the 1st and 1st columns. 2J overwrites all the characters that are currently on the screen.

You can also use this:

 write(0,"\e[1;1H\e[2J",12); 

Then you do not need stdio.h.

+2
source

Create your own function in your own header file that contains clrscr () and uses it. eg:

 #include <stdlib.h> void clrscr() { system("cls"); } 

save it as "ClearScreen.h" in your path to the "include" folder (for ex - C: \ Program Files (x86) \ CodeBlocks \ MinGW \ include)

compile it.

now use it in your programs, for example:

 #include <stdio.h> #include <conio.h> #include <ClearScreen.h> main() { clrscr(); printf("\nHi"); getch(); return 0; } 

now compile and run it. I hope this works.

0
source

conio.h for linux

download: http://sourceforge.net/projects/conio4linux/?source=typ_redirect

copy to / usr / include

Example:

root @ shu-GA-VT890P: / usr / include # ls | grep conio

:)

checked by code :: blocks in ubuntu 14.10

0
source

I just searched the web.

It is impossible to remember the source, but this should be the most accurate so far.

 #include<windows.h> void clear_screen () { DWORD n; /* Number of characters written */ DWORD size; /* number of visible characters */ COORD coord = {0}; /* Top left screen position */ CONSOLE_SCREEN_BUFFER_INFO csbi; /* Get a handle to the console */ HANDLE h = GetStdHandle ( STD_OUTPUT_HANDLE ); GetConsoleScreenBufferInfo ( h, &csbi ); /* Find the number of characters to overwrite */ size = csbi.dwSize.X * csbi.dwSize.Y; /* Overwrite the screen buffer with whitespace */ FillConsoleOutputCharacter ( h, TEXT ( ' ' ), size, coord, &n ); GetConsoleScreenBufferInfo ( h, &csbi ); FillConsoleOutputAttribute ( h, csbi.wAttributes, size, coord, &n ); /* Reset the cursor to the top left position */ SetConsoleCursorPosition ( h, coord ); } 

Now you only need to call clear_screen()

EDIT:

Just found a source: http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1031963460&id=1043284385

0
source
 #include <stdlib.h> int main() { system("cls"); } 

or you can just add a system ("cls"); in your main function. Note: this requires the stdlib.h file, so be sure to include it.

0
source

open conio.h in the "MinGW \ include" folder, just add these lines to the very bottom and save conio.h

 #include <stdlib.h> void clrscr() { system("cls"); } 

thats all now your clrscr (); will work

0
source
 void function MyClearScreen() { asm { mov ax,0600h; mov bh,71h; mov cx,0000h; mov dx,184Fh; int 10h; }; }; int main() { MyClearScreen(); } 
0
source

You can use OS commands to clear the contents of the console.

 #include<stdlib.h> int main(){ system("cls"); //For windows system("clear"); //For Linux } 
0
source
 #include<conio.h> #include<iostream.h> int main() { //using namespace std clrscr(); } 

// try this and let me know if this works

-1
source

Source: https://habr.com/ru/post/950010/


All Articles