C语言中的cleardevice()函数

头文件显示图形。h包含 cleardevice() 在图形模式下清除屏幕并将当前位置设置为(0,0)的功能。清除屏幕包括用当前背景色填充屏幕。

null

语法:

void cleardevice();

下面是cleardevice()在C中的实现:

// C Implementation for cleardevice()
#include <graphics.h>
// driver code
int main()
{
// gm is Graphics mode which is
// a computer display mode that
// generates image using pixels.
// DETECT is a macro defined in
// "graphics.h" header file
int gd = DETECT, gm;
// initgraph initializes the
// graphics system by loading a
// graphics driver from disk
initgraph(&gd, &gm, "" );
// set the background colour as GREEN
setbkcolor(GREEN);
// outtext function displays
// text at current position.
outtext( "Press any key to clear the screen." );
getch();
// cleardevice function
cleardevice();
outtext( "Press any key to exit..." );
getch();
// closegraph function closes the
// graphics mode and deallocates
// all memory allocated by
// graphics system .
closegraph();
return 0;
}


输出:

On executing the program, the output window looks like :
图片[1]-C语言中的cleardevice()函数-yiteyi-C++库
On pressing any key :
图片[2]-C语言中的cleardevice()函数-yiteyi-C++库
To exit, press any key.
图片[3]-C语言中的cleardevice()函数-yiteyi-C++库
© 版权声明
THE END
喜欢就支持一下吧
点赞6 分享