Solved

How to clear screen in borland C++?

Posted on 1997-08-08
1
1,683 Views
Last Modified: 2006-11-17
What do I have to type to clear the screen with Borlan C++?
0
Comment
Question by:Nectaire
1 Comment
 
LVL 1

Accepted Solution

by:
mosfet earned 50 total points
ID: 1167040
If you want to use a C++ function, and it is in text mode, use clrscr().

If you want to use a C++ function, and you're in graphics mode, and using the built in graphics functions, use cleardevice().

If you want to write your own C++ function for text, here's one:

void clear_screen() {
 char far *scr=(char far *)0xB8000000L;
 int n;

 for (n=0;n<2000;n++) {
  scr[n*2]=0x20;
  scr[n*2+1]=0x07;
 }
}

If you want to write your own C++ function for graphics, here's one:

#define SCREEN_WIDTH ?  // Fill these in yourself
#define SCREEN_HEIGHT ?

void clear_graphics_screen() {
 char far *scr=(char far *)0xA0000000L;
 unsigned long n;

  for (n=0;n<SCREEN_WIDTH*SCREEN_HEIGHT;n++) {
   scr[n]=0;
  }
}

0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question