c++ linux terminal 清屏函数,鬼火大侠,c++的console清屏函数是什么??

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

C++里面木有这个(也不要去想cconio~,这是一个特例)

BCB可以是因为BCB的库里面已经替你实现了呵呵。

解决办法:

1.偶一直用的超级呆办法:

void cls(void)

{

int i=0;

for(;i<30;i++)cout<

return;

}

2.调用系统的,可惜不能跨平台:stdlib.h中的老调调:system()

void cls(void)

{

#ifdef UNIX

system("clear");

#else

system("cls");

#endif

return;

}

3.抄袭clrscr原代码:仅供参考~~>_<

/* 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 */

/* get the number of character cells in the current buffer */

bSuccess = GetConsoleScreenBufferInfo( hConsole, &csbi );

PERR( bSuccess, "GetConsoleScreenBufferInfo" );

dwConSize = csbi.dwSize.X * csbi.dwSize.Y; /* fill the entire screen with blanks */

bSuccess = FillConsoleOutputCharacter( hConsole, (TCHAR) ' ', dwConSize, coordScreen, &cCharsWritten );

PERR( bSuccess, "FillConsoleOutputCharacter" ); /* get the current text attribute */

bSuccess = GetConsoleScreenBufferInfo( hConsole, &csbi );

PERR( bSuccess, "ConsoleScreenBufferInfo" ); /* now set the buffer's attributes accordingly */

bSuccess = FillConsoleOutputAttribute( hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten );

PERR( bSuccess, "FillConsoleOutputAttribute" ); /* put the cursor at (0, 0) */

bSuccess = SetConsoleCursorPosition( hConsole, coordScreen );

PERR( bSuccess, "SetConsoleCursorPosition" );

return;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值