Solved

Clearing the Screen

Posted on 1998-12-03
6
258 Views
Last Modified: 2006-11-17
I have a program in c++ using dos windows.  I would like to know the syntax of clearing the screen between my menus.  I believe I have to use the dos.h, but do not know the code for doing this.          
                                  Thanks
0
Comment
Question by:macro091998
  • 2
  • 2
  • 2
6 Comments
 
LVL 2

Accepted Solution

by:
trillo earned 50 total points
ID: 1179170
use the clrscr function defined in conio.h

#include <conio.h>
void clrscr(void);

Trillo
0
 

Author Comment

by:macro091998
ID: 1179171
I tried using conio.h and the function void clrscr(void).  It compiled alright, but it would not link.  It had two errors:  Sales array.obj : error LNK2001: unresolved external symbol "void __cdecl clrscr(void)" (?clrscr@@YAXXZ), and Debug/CPP_CLASS.exe : fatal error LNK1120: 1 unresolved externals

It stops linking at the function call.  I also think conio.h is a Borland library function.  I'm using Visual C++ 6.0  If you now something that could help me, let me know...
       
THANKS
Macro

0
 
LVL 2

Expert Comment

by:trillo
ID: 1179172
Hmmm..... you're right, that's Borland's.... I've looked around and I came to the conclusion that Microsoft doesn't have anything equivalent for clrscr().
You could try using the "system" function, (I think it's defined in <stdlib.h>) and passing the "cls" DOS command...

{
   ...
   system("cls");
   ...
}

Not very good, huh? (At least not as good as clrscr), but it may be a soultion..

Trillo
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 22

Expert Comment

by:nietod
ID: 1179173
The problem is that your are not writing a DOS program.  VC 6 does not support DOS.  (VC 2 and later don't support DOS).

You are writting a win 32 console program.  This is a windows program (it can have windows like any other) but by default starts with a console window that displays text like a DOS program does.  (However, it can do much more.)  I recomend you look up console programs in the docs to see that it is that you really are workign woth.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1179174
To get started, look up "Consoles and Character Mode Supprt"

I don't see any procedure for clearing the screen.  But you can write one using SetConsoleCursorPosition() and WriteConsole().  You could also use WriteConsoleOutput().  (There are a lot of ways, actually.  You need to do some research.)

Let me know if you have questions.

0
 

Author Comment

by:macro091998
ID: 1179175
trillo,
  Using the <stdlib.h> and system("cls") worked great... THANKS  macro
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
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++.

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now