ok so if i have somthing like

#include <iostream>

using namespace std;

int main(){
    int action;
    cout << "have this show up first" << endl;
    cout << "then have an if statement here" << endl;
    cin >> action;
    if (action == 1){
               cout << "then have this show up but none of the above text ^^." << endl;
               }
    system("pause");
    return 0;
    
    }

how would i do that so it does what it says in the "cout"?

i tried that it didnt work it when i put in the IF statement it got rid of all the stuff...

It worked when I did it just now:

if (action == 1){
               system("cls");
               cout << "then have this show up but none of the above text ^^." << endl;
               }

According to this site you can also use clrscr(); if you have Borland C++ Builder.

Edited 6 Years Ago by MyrtleTurtle: n/a

Could you please give us an example of what you want rather than half an explanation using strange code?

ok so what i want is for me to be able to go through my script and as i go to another item it gets rid of the previous text...
heres an example...

#include <iostream>
using namespace std;

 int Mainmenu();
 char action1;
 int action;
using namespace std;
int Unitedstates()
{
int action;
char action1;
cout << "you have chosen to learn more about the united states. Now What will you do?" << endl;
cout << "1. The quality of doctors in the United States." << endl;
cout << "2. What happens when a doctor commites malpractice." << endl;
cout << "3. Average salery of doctors." << endl;
cout << "4. Practices in  the United States." << endl;
cin >> action;
if (action == 1){
           cout << "Coming soon" << endl;
           }
else if (action == 2){
     cout << "coming soon" << endl;
     }
else if (action == 3){
     cout << "the average salery is $100,000 a year." << endl;
     }
else if (action == 4){
cout << "coming soon" << endl;
}
else {cin >> action;}
}

int Europe(){
int action;
char action1;
cout << "You have chosen to learn more about Medecine in Europe." << endl;
cout << "Now what do you want to learn about?" << endl;
cout << "1. The quality of doctors in Europe." << endl;
cout << "2. What happens when a doctor commites malpractice." << endl;
cout << "3. Average salery of doctors." << endl;
cout << "4. Practices in  the Europe." << endl;
cin >> action;
if (action== 1){
cout << "coming soon" << endl;
cout << "to go back to the main menu, press 1, and then enter." << endl;
cin >> action;
if (action == 1)
cout << Mainmenu();
else cin >> action;
}
else if (action == 2){
cout << "coming soon" << endl;
cout << "to go back to the main menu, press 1, and then enter." << endl;
cin >> action;
if (action == 1)
cout << Mainmenu();
else cin >> action;
}
else if (action == 3){
cout << "coming soon" << endl;
cout << "to go back to the main menu, press 1, and then enter." << endl;
cin >> action;
if (action == 1)
cout << Mainmenu();
else cin >> action;
}
else if (action == 4){
cout << "coming soon" << endl;
cout << "to go back to the main menu, press 1, and then enter." << endl;
cin >> action;
if (action == 1)
cout << Mainmenu();
else cin >> action;
     }
else cin >> action;
}


int China(){
cout << "You have chosen to learn more about Medecine in China." << endl;
cout << "Now what do you want to learn about?" << endl;
cout << "1. The quality of doctors in China." << endl;
cout << "2. What happens when a doctor commites malpractice." << endl;
cout << "3. Average salery of doctors." << endl;
cout << "4. Practices in China." << endl;
cin >> action;
if (action== 1){
cout << "coming soon" << endl;
cout << "to go back to the main menu, press 1, and then enter." << endl;
cin >> action;
if (action == 1)
cout << Mainmenu();
else cin >> action;
}
else if (action == 2){
cout << "coming soon" << endl;
cout << "to go back to the main menu, press 1, and then enter." << endl;
cin >> action;
if (action == 1)
cout << Mainmenu();
else cin >> action;
}
else if (action == 3){
cout << "coming soon" << endl;
cout << "to go back to the main menu, press 1, and then enter." << endl;
cin >> action;
if (action == 1)
cout << Mainmenu();
else cin >> action;
}
else if (action == 4){
cout << "coming soon" << endl;
cout << "to go back to the main menu, press 1, and then enter." << endl;
cin >> action;
if (action == 1)
cout << Mainmenu();
else cin >> action;
     }
else cin >> action;
}


int Australia(){
cout << "You have chosen to learn more about Medecine in Australia." << endl;
cout << "Now what do you want to learn about?" << endl;
cout << "1. The quality of doctors in Europe." << endl;
cout << "2. What happens when a doctor commites malpractice." << endl;
cout << "3. Average salery of doctors." << endl;
cout << "4. Practices in  Australia." << endl;
cin >> action;
if (action== 1){
cout << "coming soon" << endl;
cout << "to go back to the main menu, press 1, and then enter." << endl;
cin >> action;
if (action == 1)
cout << Mainmenu();
else cin >> action;
}
else if (action == 2){
cout << "coming soon" << endl;
cout << "to go back to the main menu, press 1, and then enter." << endl;
cin >> action;
if (action == 1)
cout << Mainmenu();
else cin >> action;
}
else if (action == 3){
cout << "coming soon" << endl;
cout << "to go back to the main menu, press 1, and then enter." << endl;
cin >> action;
if (action == 1)
cout << Mainmenu();
else cin >> action;
}
else if (action == 4){
cout << "coming soon" << endl;
cout << "to go back to the main menu, press 1, and then enter." << endl;
cin >> action;
if (action == 1)
cout << Mainmenu();
else cin >> action;
     }
else cin >> action;
}



int Africa(){
cout << "You have chosen to learn more about Medecine in Africa." << endl;
cout << "Now what do you want to learn about?" << endl;
cout << "1. The quality of doctors in Europe." << endl;
cout << "2. What happens when a doctor commites malpractice." << endl;
cout << "3. Average salery of doctors." << endl;
cout << "4. Practices in  Africa." << endl;
cin >> action;
if (action== 1){
cout << "coming soon" << endl;
cout << "to go back to the main menu, press 1, and then enter." << endl;
cin >> action;
if (action == 1)
cout << Mainmenu();
else cin >> action;
}
else if (action == 2){
cout << "coming soon" << endl;
cout << "to go back to the main menu, press 1, and then enter." << endl;
cin >> action;
if (action == 1)
cout << Mainmenu();
else cin >> action;
}
else if (action == 3){
cout << "coming soon" << endl;
cout << "to go back to the main menu, press 1, and then enter." << endl;
cin >> action;
if (action == 1)
cout << Mainmenu();
else cin >> action;
}
else if (action == 4){
cout << "coming soon" << endl;
cout << "to go back to the main menu, press 1, and then enter." << endl;
cin >> action;
if (action == 1)
cout << Mainmenu();
else cin >> action;
     }
else cin >> action;
}



int Brazil(){
cout << "You have chosen to learn more about Medecine in Brazil." << endl;
cout << "Now what do you want to learn about?" << endl;
cout << "1. The quality of doctors in Europe." << endl;
cout << "2. What happens when a doctor commites malpractice." << endl;
cout << "3. Average salery of doctors." << endl;
cout << "4. Practices in  Brazil." << endl;
cin >> action;
if (action== 1){
cout << "coming soon" << endl;
cout << "to go back to the main menu, press 1, and then enter." << endl;
cin >> action;
if (action == 1)
cout << Mainmenu();
else cin >> action;
}
else if (action == 2){
cout << "coming soon" << endl;
cout << "to go back to the main menu, press 1, and then enter." << endl;
cin >> action;
if (action == 1)
cout << Mainmenu();
else cin >> action;
}
else if (action == 3){
cout << "coming soon" << endl;
cout << "to go back to the main menu, press 1, and then enter." << endl;
cin >> action;
if (action == 1)
cout << Mainmenu();
else cin >> action;
}
else if (action == 4){
cout << "coming soon" << endl;
cout << "to go back to the main menu, press 1, and then enter." << endl;
cin >> action;
if (action == 1)
cout << Mainmenu();
else cin >> action;
     }
else cin >> action;
}




int Mainmenu(){
int action;
char action1;
 cout << "Welcome to my Quarter Project." << endl;
 cout << "What would you like to learn more about?" << endl;
 cout << "1. Medecine in the United States." << endl;
 cout << "2. Medecine in Europe." << endl;
 cout << "3. Medecine in China." << endl;
 cout << "4. Medecine in Australia." << endl;
 cout << "5. Medecine in Africa." << endl;
 cout << "6. Medecine in Brazil." << endl;
 cin >> action;
 if (action == 1)cout << Unitedstates();
 else if (action == 2) cout << Europe();
 else if (action == 3) cout << China();
 else if (action == 4) cout << Australia();
 else if (action == 5) cout << Africa;
 else if (action == 6) cout << Brazil();
else {cin >> action;}



}




int main()
{
int action;
char action1;
cout << Mainmenu();

 system("pause");
 return 0;

}

thats my script and i want it to be able to like as i go from "mainmenu" to say Europe, the main menu dosnt show up anymore and then if i pick something in Europe it makes the previous text disappear and only show whats next

Then just put the system("cls"); command immediately before the new menu is displayed.

We usually don't recommend doing things like this though because there is no standard way to clear the screen. It's different for each O/S.

This article has been dead for over six months. Start a new discussion instead.