You are here

Cleardevice function in c

Declaration: void cleardevice();
cleardevice function clears the screen in graphics mode and sets the current position to (0,0). Clearing the screen consists of filling the screen with current background color.

C program for cleardevice

#include <graphics.h>
#include <conio.h>

main()
{
   int gd = DETECT, gm;
   initgraph(&gd, &gm, "C:\\TC\\BGI");

   outtext("Press any key to clear the screen.");
   getch();
   cleardevice();
   outtext("Press any key to exit...");
   
   getch();
   closegraph();
   return 0;
}

Note : Don't use clrscr in graphics mode.