コードブロックで出力コンソールをクリアする方法?? なぜ clrscr(); しないのですか? Code::Blocks で動作しますが、Borland で動作しますか??
私はすでに試しました:
cout << "\x1b[2J\x1b[1;1H" << flush;
cls() ;
コードブロックで出力コンソールをクリアする方法?? なぜ clrscr(); しないのですか? Code::Blocks で動作しますが、Borland で動作しますか??
私はすでに試しました:
cout << "\x1b[2J\x1b[1;1H" << flush;
cls() ;
インターネットで検索しただけです。
ソースを思い出せませんが、これが今のところ最も正確なはずです。
#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 );
}
今、あなたがしなければならないのは、電話するだけです clear_screen()
編集:
ソースを見つけました: http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1031963460&id=1043284385
「MinGW\include」フォルダーの conio.h を開き、これらの行を一番下に追加して conio.h を保存します。
#include <stdlib.h>
void clrscr()
{
system("cls");
}
clrscr(); これですべてです。動作します
#include <stdlib.h>
int main()
{
system("cls");
}
または、system("cls"); を追加するだけです。あなたの主な機能で。注: stdlib.h ヘッダー ファイルが必要なので、含めることを忘れないでください。