2

I'm working on a program with menus, but I don't know how to clear the screen before displaying the next menu.

8
Contributors
12
Replies
15
Views
13 Years
Discussion Span
Last Post by wildrider30
2

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

0

nope clearing a terminal window is hadnled by the operating system's kernal, exclusively.

0

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

cout << "\b\b\b\b\b\b";

or you could cout the ascii equivilent;)

1

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

0

hey i tried to clear screen using "conio.h> but it doesnt work then i tried again using
<process.h> or <windows.h> and it work good .. :D

1

Actually the <conio,h> works....atleast if u use "void main()"
N you shud add the "clrscr();" after the opening braces....(but not towards the end...as ur result will get wiped out before being 'outputted')

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.