943,510 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 6979
  • C++ RSS
You are currently viewing page 1 of this multi-page discussion thread
Mar 17th, 2004
2

Clearing the screen

Expand Post »
I'm working on a program with menus, but I don't know how to clear the screen before displaying the next menu.
Similar Threads
Reputation Points: 12
Solved Threads: 0
Newbie Poster
Lost Chyld is offline Offline
6 posts
since Mar 2004
Mar 21st, 2004
2

Re: Clearing the screen

if its just in the dos screen

#include <iostream>
#include <cstdlib>

using namespace std;

int main()
{
cout << "Hello World!" << endl;
system("cls");
cout << "End of program";
system("pause");
return 0;
}

you can put any dos command in the quotes... but make sure you include cstdlib
Reputation Points: 45
Solved Threads: 0
Light Poster
Bleek is offline Offline
28 posts
since Mar 2004
Mar 23rd, 2004
1

Re: Clearing the screen

linux: system("clear");
Reputation Points: 47
Solved Threads: 2
Junior Poster in Training
infamous is offline Offline
77 posts
since Mar 2004
Mar 24th, 2004
0

Re: Clearing the screen

Thanx guys.
Reputation Points: 12
Solved Threads: 0
Newbie Poster
Lost Chyld is offline Offline
6 posts
since Mar 2004
May 2nd, 2004
2

Re: Clearing the screen

thnx guys but is there any anther way to do that without <cstdlib>?
Team Colleague
Reputation Points: 55
Solved Threads: 3
Junior Poster
meabed is offline Offline
139 posts
since May 2004
May 2nd, 2004
0

Re: Clearing the screen

nope clearing a terminal window is hadnled by the operating system's kernal, exclusively.
Reputation Points: 28
Solved Threads: 9
Posting Whiz in Training
BountyX is offline Offline
222 posts
since Mar 2004
May 2nd, 2004
0

Re: Clearing the screen

actually there is a way around that... you could cout a bunch of back spaces...

C++ Syntax (Toggle Plain Text)
  1. cout << "\b\b\b\b\b\b";

or you could cout the ascii equivilent
Reputation Points: 45
Solved Threads: 0
Light Poster
Bleek is offline Offline
28 posts
since Mar 2004
May 4th, 2004
1

Re: Clearing the screen

Yea u can...backspaces need to b calculated...however thers a simple approach to the problem
jus print the required number of newline chars i.e '\n'
use the following code:
for(int i=1;i<26;i++)
cout<<"\n';

if ur program works on a loop structure then i'd suggest using the system("clear") option (Linux) or system("cls") for Windows
Reputation Points: 11
Solved Threads: 0
Newbie Poster
Snyper is offline Offline
2 posts
since May 2004
May 4th, 2004
1

Re: Clearing the screen

#include <conio.h>
......
main() {
.....
clrscr();
.....
}
Reputation Points: 11
Solved Threads: 0
Newbie Poster
skywing is offline Offline
5 posts
since May 2004
May 11th, 2004
0

Re: Clearing the screen

Thnx Guys
Team Colleague
Reputation Points: 55
Solved Threads: 3
Junior Poster
meabed is offline Offline
139 posts
since May 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: creating a grammer checker in c++
Next Thread in C++ Forum Timeline: Program design (help)





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC