vc++的清屏函数是什么啊? vc++的清屏函数是什么啊? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 没有清屏函数不过有个相当与清屏的代码:#include <stdio.h>#include "stdafx.h"#include <windows.h>#include <tchar.h>#include <conio.h>void ClearScreen();int main(int argc, char* argv[]){for (int i=0;i<10;i++)printf("%d,Hello World!\n",i);printf("press any key to clear screen\n");getch();ClearScreen();printf("done!\n");getch();return 0;}void ClearScreen(){HANDLE hOutput=GetStdHandle(STD_OUTPUT_HANDLE);CONSOLE_SCREEN_BUFFER_INFO sbi;GetConsoleScreenBufferInfo(hOutput,&sbi);//计算到光标在缓冲中的偏移DWORD len=sbi.dwSize.X*sbi.dwCursorPosition.Y+sbi.dwCursorPosition.X+1;COORD cd={0,0};DWORD nw;//全部填充空格FillConsoleOutputCharacter(hOutput,_T(' '),len,cd,&nw); //搞掂,光标回到最上角开始处SetConsoleCursorPosition(hOutput,cd);} HOWTO: Performing Clear Screen (CLS) in a Console Application Q99261--------------------------------------------------------------------------------The information in this article applies to:Microsoft Win32 Application Programming Interface (API), used with:the operating system: Microsoft Windows NT, versions 3.51, 4.0 Microsoft Windows 95 the operating system: Microsoft Windows 2000--------------------------------------------------------------------------------SUMMARYSome non-Microsoft versions of C++ provide a clrscr function for clearing the screen in a DOS application. However, there is no Win32 Application Programming Interface (API) or C-Runtime function that will perform this function.There are two ways to accomplish this task for a Win32 console application. The first method is to use the system function as follows:#include <stdlib.h>void main(){ system("cls");} The second method is to write a function that will programmatically clear the screen. That method is described in the More Information section which follows. MORE INFORMATIONThe following function clears the screen: /* 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; } Additional query words: clearscreen Keywords : kbcode kbAPI kbConsole kbKernBase kbOSWinNT351 kbOSWinNT400 kbOSWin2000 kbDSupport kbGrpDSKernBase Issue type : kbhowto Technology : kbOSWin2000 kbOSWinNT kbOSWinSearch Last Reviewed: December 14, 2000© 2001 Microsoft Corporation. All rights reserved. Terms of Use. --------------------------------------------------------------------------------Send feedback to MSDN.Look here for MSDN Online resources. bljbljbljblj(LPTSTR)(LPCTSTR) .........你得名字也太那个了 .............不过你得答案不长........ MFC 对话框的一个小问题 怎样将字符串转换成16进制字符数据啊? socket发送数据问题? 整WIN-CE的,想学学VC,请各位大侠给点建议 ~文本分析的问题 五种套节字IO模型,CPU占用率有区别么? 好奇的问个小问题 用vc的时候,我没有设置断点,为什么debug会有user breakpoint出现?大家帮帮忙。 VC如何对word文档不同字设置不同颜色 求一网址 ???不同类能重复定义变量??? 高难度问题:如何阻止用户在操作系统中以各种方式修改系统时间(在Dos 和 Windows 系统中)
不过有个相当与清屏的代码:
#include <stdio.h>
#include "stdafx.h"
#include <windows.h>
#include <tchar.h>
#include <conio.h>
void ClearScreen();
int main(int argc, char* argv[])
{
for (int i=0;i<10;i++)
printf("%d,Hello World!\n",i);
printf("press any key to clear screen\n");
getch();
ClearScreen();
printf("done!\n");
getch();
return 0;
}
void ClearScreen()
{
HANDLE hOutput=GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO sbi;
GetConsoleScreenBufferInfo(hOutput,&sbi);
//计算到光标在缓冲中的偏移
DWORD len=sbi.dwSize.X*sbi.dwCursorPosition.Y+sbi.dwCursorPosition.X+1;
COORD cd={0,0};
DWORD nw;
//全部填充空格
FillConsoleOutputCharacter(hOutput,_T(' '),len,cd,&nw);
//搞掂,光标回到最上角开始处
SetConsoleCursorPosition(hOutput,cd);
}
--------------------------------------------------------------------------------
The information in this article applies to:Microsoft Win32 Application Programming Interface (API), used with:
the operating system: Microsoft Windows NT, versions 3.51, 4.0
Microsoft Windows 95
the operating system: Microsoft Windows 2000--------------------------------------------------------------------------------
SUMMARY
Some non-Microsoft versions of C++ provide a clrscr function for clearing the screen in a DOS application. However, there is no Win32 Application Programming Interface (API) or C-Runtime function that will perform this function.There are two ways to accomplish this task for a Win32 console application. The first method is to use the system function as follows:#include <stdlib.h>void main()
{
system("cls");
}
The second method is to write a function that will programmatically clear the screen. That method is described in the More Information section which follows. MORE INFORMATION
The following function clears the screen:
/* 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;
} Additional query words: clearscreen Keywords : kbcode kbAPI kbConsole kbKernBase kbOSWinNT351 kbOSWinNT400 kbOSWin2000 kbDSupport kbGrpDSKernBase
Issue type : kbhowto
Technology : kbOSWin2000 kbOSWinNT kbOSWinSearch
Last Reviewed: December 14, 2000
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.
--------------------------------------------------------------------------------
Send feedback to MSDN.Look here for MSDN Online resources.
你得名字也太那个了 .............不过你得答案不长........