Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clearing the screen

Status
Not open for further replies.

piked

Programmer
May 7, 2002
14
0
0
AU
Hello.

Was just wondering if there's a C function to clear the screen, in dos.. without pumping it full of newlines.. the equivalent of CLS, essentially.

Thanks.
 
u can use the function

clrscr()

to clear the screen. in case u want to set the background to say blue after the screen is cleared, then use the following commands

textbackground(BLUE);
clrscr();

pl. note the correct header files are required for using this command.


also u can clear a window portion from the screen, the syntax is

window(tcol, trow, bcol, brow);


where tcol and trow represent top column and row and bcol and brow represents bottom column and row.


textbackground(BLUE);
clrscr();
textbackground(RED);
window(20, 10, 50, 20);
clrscr();
window(1,1,80,25);

the above commands first clears the screen and sets the screen color to blue, next creates a window from 10th row 20th column to 20th row 50th column with red background.

try out and do get back to this forum with your comments.




icici
 
If you work on MS-DOS, it will be simple.
Just include the header file conio.h, and call the clrscr() function. Just like icici said.
But if you program in Unix/Linux, there's no conio.h file in there. So you gotta do it with printf() function (I think there's other way too). Sorry I forgot the code :) (but you can still look for it, just run the KDevelop if you're using Red Hat, and try to look for it in Help).
 
This also works:

#include<stdlib.h>
....
system(&quot;cls&quot;);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top