Re: Clearing the screen - Press any key...
From: Ulrich Eckhardt (doomster_at_knuut.de)
Date: 09/01/04
- Next message: Steve: "Re: Clearing the screen - Press any key..."
- Previous message: Jonathan Turkanis: "Re: C++ unit testing"
- In reply to: Steve: "Clearing the screen - Press any key..."
- Next in thread: Steve: "Re: Clearing the screen - Press any key..."
- Reply: Steve: "Re: Clearing the screen - Press any key..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 01 Sep 2004 07:09:13 +0200
Steve wrote:
> //Sample code for pressing any key to continue...
> char anykey;
> cout << "Press any key to continue...";
> cin >> anykey;
> cout <<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
> //End sample
>
> So that code requires that you actually enter some character before
> pressing enter. How do you make it so that you can simply press the
> space bar and press enter to clear the screen?
std::cout << "<enter>" << std::flush;
std::string str;
std::getline( std::cin, str);
> Also is there a better way to clear the screen other than using
> \n\n\n\n\n\n\n\n\n\n (the method for clearning the screen must be an
> ANSI/ISO Standard C++ command/code).
No, there isn't.
For text-based, menu driven programs, you should take a look at one of the
curses libraries. They feature much more, e.g. tracking single keypresses
and positioning the cursor and are available for a wide range of
platforms.
Uli
-- FAQ: http://ma.rtij.nl/acllc-c++.FAQ.html
- Next message: Steve: "Re: Clearing the screen - Press any key..."
- Previous message: Jonathan Turkanis: "Re: C++ unit testing"
- In reply to: Steve: "Clearing the screen - Press any key..."
- Next in thread: Steve: "Re: Clearing the screen - Press any key..."
- Reply: Steve: "Re: Clearing the screen - Press any key..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|