CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Clear screen

  1. #1
    Join Date
    May 1999
    Posts
    8

    Clear screen

    Hi,
    I am writing a OOP program which create menu using cout. I am not using MFC or
    graphic programming. Just simple standard OOP C++ language. Once I select option# from my menu, it will create sub-menu. But the problem is I want to clear the screen from standard output and then sub-menu should written to standard output. I tried but I could not find a key which will clear the standard output. Any suggestions?

    Thanks,

    Sandeep


  2. #2
    Join Date
    Apr 1999
    Posts
    383

    Re: Clear screen

    For a quick screen clear, you could output sufficient new lines to scroll any text off the console window...

    Otherwise, have a look at the Console Functions such as
    ScrollConsoleScreenBuffer, FillConsoleOutputCharacter, etc.

    Dave



  3. #3
    Join Date
    May 1999
    Location
    Seattle, WA USA
    Posts
    423

    Re: Clear screen

    for a normal console app, you can use

    System ("cls");

    --michael


  4. #4
    Join Date
    May 1999
    Location
    UK
    Posts
    65

    Re: Clear screen

    The Alternative which is better than A System Command or Outputting lines is to use old fashioned Escape characters like 27 73




  5. #5
    Guest

    Re: Clear screen

    Another easy way is :

    int main()
    {
    cout << "the command bellow gonna clear the screen, let's try this...";
    cout << "\x1b[2J"; // CLEAR SCREEN

    // You need to path ansi.sys into your config.sys (and the \x1b[2J gonna do job
    }


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured