• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 162
  • Last Modified:

simple clear screen question

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
Pmesick
Asked:
Pmesick
  • 3
  • 2
1 Solution
 
ExceterCommented:
What compiler are you using?
0
 
PmesickAuthor Commented:
MSVisual C++
0
 
ExceterCommented:
If your compiler soes not have such a library function you can always try,

system("cls");

Exceter
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
ExceterCommented:
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
 
thienpnguyenCommented:
#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
 
PmesickAuthor Commented:
Thanks alot!
Strange something so easy is so complicated.  

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

Featured Post

Independent Software Vendors: 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!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now