English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

請問一下 清除營幕指令是什 不論我用clrscr()或 _cleanscreen(0) 都不行><

2006-05-03 09:22:37 · 1 個解答 · 發問者 國宏 1 in 電腦與網際網路 程式設計

1 個解答

1.最簡單就是用system("cls");
2.寫一function去填空白
void cls( HANDLE hConsole )
{
COORD coordScreen = { 0, 0 }; // home for the cursor
DWORD cCharsWritten;
CONSOLE_SCREEN_BUFFER_INFO csbi;
DWORD dwConSize;

// Get the number of character cells in the current buffer.

if( !GetConsoleScreenBufferInfo( hConsole, &csbi ))
return;
dwConSize = csbi.dwSize.X * csbi.dwSize.Y;

// Fill the entire screen with blanks.

if( !FillConsoleOutputCharacter( hConsole, (TCHAR) ' ',
dwConSize, coordScreen, &cCharsWritten ))
return;

// Get the current text attribute.

if( !GetConsoleScreenBufferInfo( hConsole, &csbi ))
return;

// Set the buffer's attributes accordingly.

if( !FillConsoleOutputAttribute( hConsole, csbi.wAttributes,
dwConSize, coordScreen, &cCharsWritten ))
return;

// Put the cursor at its home coordinates.

SetConsoleCursorPosition( hConsole, coordScreen );
}

2006-05-03 10:36:39 · answer #1 · answered by chan 5 · 0 0

fedest.com, questions and answers