Cleardevice() Function

cleardevice() is a function which is used to clear the screen by filling the whole screen with the current background color. It means that cleardevice() function is used to clear the whole screen with the current background color and it also sets the current position to (0,0). . Both clrscr() and cleardevice() functions are used to clear the screen but clrscr() is used in text mode and cleardevice function is used in the graphics mode.

void cleardevice();

Program

#include<stdio.h>

#include<conio.h>

#include<graphics.h>

void main()

{

int gd=DETECT,gm;

initgraph(&gd,&gm," ");

circle(320,240,100);

outtext("enter any character to clear the screen:");

getch();

cleardevice();

outtext("enter any character to exit..................");

getch();

closegraph();

}

Above program shows the use of function cleardevice() in the C graphics..

Output

After running the above program first of all a circle with radius 100cm and a message "enter any character to clear the screen" will display on the screen as given below: cgraph And when we input any character then screen will be cleared and a message will be produced "enter any character to exit.................." as given below: cgraph and now you can enter a character to exit from the program...