system("cls")
在VC环境下有两种办法实现清屏: 1.#include system("cls"); 这种办法的缺点是程序额外运行系统程序执行清屏操作,延长了程序执行时间。
基本内容
在VC环境下有两种办法实现清屏:
1.#include <windows.h>
system("cls");
这种办法的缺点是程序额外运行系统程序执行清屏操作,延长了程序执行时间。
2.自己写函数,这种办法快
这是从微软MSDN得到的方法:
/* Standard error macro for reporting API errors */
#define PERR(bSuccess, api){if(!(bSuccess)) printf("%s:Error %d from %s \
on line %d\n", __FILE__, GetLastError(), api, __LINE__);}
void cls( HANDLE hConsole )
{
COORD coordScreen = { 0, 0 }; /* here's where we'll home the
cursor */
BOOL bSuccess;
DWORD cCharsWritten;
CONSOLE_SCREEN_BUFFER_INFO csbi; /* to get buffer info */
DWORD dwConSize; /* number of character cells in
the current buffer */