PRODUCT : TURBO C NUMBER : 452 VERSION : 2.O OS : PC-DOS DATE : FEBRUARY 2, 1989 PAGE : 1/2 TITLE : ERASING CHARACTERS (OR "TEXT") The following program demonstrates two methods of removing previously displayed characters. The first method uses the bar function to erase the desired area of the screen. The second method involves overwriting the font in the current background color. Both methods are effective, and the choice of methods would be based on the needs of the particular application. #include #include main() { int driver = DETECT; /* autodetect driver */ int mode; int oldcolor; int x=10; int y=10; char string1[] = "Hello"; char string2[] = "world"; char string3[] = "Goodbye"; initgraph(&driver, &mode, ""); outtextxy(x, y, string1); /* print a string */ sleep(1); /* wait a second */ /*** erase text by drawing a bar ***/ setfillstyle(SOLID_FILL, getbkcolor()); bar(x, y, x+textwidth(string1), y+textheight(string1)); outtextxy(x, y, string2); /* print another string */ sleep(1); /* wait another second */ /*** erase the string by overwriting ***/ oldcolor = getcolor(); /* save current color */ setcolor( getbkcolor() ); /* set to background color */ outtextxy(x, y, string2); /* erase string */ setcolor(oldcolor); /* restore color */ outtextxy(x, y, string3); /* print one more string */ sleep(1); /* wait one more second */ closegraph(); return 0; } PRODUCT : TURBO C NUMBER : 452 VERSION : 2.O OS : PC-DOS DATE : FEBRUARY 2, 1989 PAGE : 2/2 TITLE : ERASING CHARACTERS (OR "TEXT") DISCLAIMER: You have the right to use this technical information subject to the terms of the No-Nonsense License Statement that you received with the Borland product to which this information pertains.