?
Solved

simple clear screen question

Posted on 2003-02-28
6
Medium Priority
?
161 Views
Last Modified: 2010-04-01
In a simple program, I want to prompt the user for stuff, then clear the screen and cout some more stuff.

My question is how to clear the screen and start from the top?
0
Comment
Question by:Pmesick
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 8

Expert Comment

by:Exceter
ID: 8045462
What compiler are you using?
0
 

Author Comment

by:Pmesick
ID: 8045490
MSVisual C++
0
 
LVL 8

Expert Comment

by:Exceter
ID: 8045499
If your compiler soes not have such a library function you can always try,

system("cls");

Exceter
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Expert Comment

by:Exceter
ID: 8045510
Check this out,
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/clearing_the_screen.asp

>> MSVisual C++

Pitty, in Borland you can simply say,

clrscr();

Exceter
0
 
LVL 6

Accepted Solution

by:
thienpnguyen earned 300 total points
ID: 8045521
#include <windows.h>


void MyClrscr()
{


    HANDLE hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);

    CONSOLE_SCREEN_BUFFER_INFO ConsoleScreenBufferInfo;
    GetConsoleScreenBufferInfo(hConsoleOutput,&ConsoleScreenBufferInfo);



    int size = ConsoleScreenBufferInfo.dwSize.X *
               ConsoleScreenBufferInfo.dwSize.Y;


    COORD UpperLeftCoord = {0,0};
    DWORD nLength;

    FillConsoleOutputAttribute(hConsoleOutput,
                               ConsoleScreenBufferInfo.wAttributes,
                               size,
                               UpperLeftCoord,
                               &nLength);

    FillConsoleOutputCharacter(hConsoleOutput,' ',size,
                               UpperLeftCoord, &nLength);

    SetConsoleCursorPosition(hConsoleOutput, UpperLeftCoord);
}

// testing
void main()
{
    MyClrscr();
}
0
 

Author Comment

by:Pmesick
ID: 8045542
Thanks alot!
Strange something so easy is so complicated.  

Excuse my easy questions, havent used c++ in 3 years.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

765 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