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

  1. #include <graphics.h>
  2. #include <conio.h>
  3.  
  4. main()
  5. {
  6.    int gd = DETECT, gm;
  7.    initgraph(&gd, &gm, "C:\\TC\\BGI");
  8.  
  9.    outtext("Press any key to clear the screen.");
  10.    getch();
  11.    cleardevice();
  12.    outtext("Press any key to exit...");
  13.    
  14.    getch();
  15.    closegraph();
  16.    return 0;
  17. }

Note : Don't use clrscr in graphics mode.