Looping Menus

Could anyone help me figure out my do while loops? I am trying to make the first menu to loop continuously until you choose to exit. Menu2 does this but I want it to return to menu once you select exit in menu2. *Don't mind the ASCII stuff it didnt paste right*

#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>

using namespace std;

int main()
{
int menu;
do {
std::cout << R"(
_______ __ __ ___ _______ ___ _ _______ __ _ _______ __ __ _______ _______ _______ __
| || | | || | | || | | || || | | | | || | | || _ || || || |
| || |_| || | | || |_| || ___|| |_| | | || |_| || |_| || _____|| ___|| |
| || || | | || _|| |___ | | | || || || |_____ | |___ | |
| _|| || | | _|| |_ | ___|| _ | | _|| || ||_____ || ___||__|
| |_ | _ || | | |_ | _ || |___ | | | | | |_ | _ || _ | _____| || |___ __
|_______||__| |__||___| |_______||___| |_||_______||_| |__| |_______||__| |__||__| |__||_______||_______||__|
)" << '\n';
system("pause");
system("cls");

std::cout << R"(
-----------------------------------------
| _______ _______ _______ ______ _______ |
|| | | _ | _ | ||
|| _____|_ _| |_| | | ||_ _||
|| |_____ | | | | |_||_| | |
||_____ | | | | | __ | | |
| _____| | | | | _ | | | | | |
||_______| |___| |__| |__|___| |_|___| |
-----------------------------------------
)" << '\n';

std::cout << R"(
------------------------------------------------------------
| ______ _______ _______ _______ ______ ______ _______ |
|| _ | | | | | _ | | || ||
|| | || | ___| | _ | | || | _ | _____||
|| |_||_| |___| | | | | |_||_| | | | |_____ |
|| __ | ___| _| |_| | __ | |_| |_____ ||
|| | | | |___| |_| | | | | |_____| ||
||___| |_|_______|_______|_______|___| |_|______||_______||
------------------------------------------------------------
)" << '\n';

std::cout << R"(
-------------------------------------------------------
| _______ ______ _______ ______ ___ _______ _______ |
|| | _ | | | || | | ||
|| | | || | ___| _ | |_ _| _____||
|| | |_||_| |___| | | | | | | | |_____ |
|| _| __ | ___| |_| | | | | |_____ ||
|| |_| | | | |___| | | | | _____| ||
||_______|___| |_|_______|______||___| |___| |_______||
-------------------------------------------------------
)" << '\n';

cout << "Welcome player to Chicken Chase!" << endl;
cout << "Select an option to begin!" << endl;
cout << "1. Start" << endl;
cout << "2. School Records" << endl;
cout << "3. Credits" << endl;
cout << "4. Exit" << endl;
cout << "Select Choice: ";
cin >> menu;
system("cls");

if (menu == 1)
{
//Start Game
cout << "Coming Soon......." << endl;
system("pause");

}
else if (menu == 2)
{
int menu2;
std::cout << R"(
Welcome to the School Records!
Here you have the option to view
the characters information and get
to know them better!
)" << '\n';
system("pause");
system("cls");
std::cout << R"(
-------------------------------------------------
| _______ ___ _______ _______ ______ _______ |
|| _ | | | _ | | _ | ||
|| |_| | | | |_| | ___| | ||_ _||
|| | | | | |___| |_||_| | |
|| | |___| _ || ___| __ | | |
|| _ | | |_| | |___| | | | | |
||__| |__|_______|_______|_______|___| |_|___| |
-------------------------------------------------
)" << '\n';
std::cout << R"(
--------------------------
| ___ _______ __ _ |
| | | | | | ||
| | | _ | |_| ||
| | | | | | ||
| ___| | |_| | _ ||
|| | | | | ||
||_______|_______|_| |__||
--------------------------
)" << '\n';
std::cout << R"(
----------------------
| _______ ___ ___ |
|| _ | | | ||
|| |_| | | | ||
|| | | | ||
|| | |___| ||
|| _ | | ||
||__| |__|_______|___||
----------------------
)" << '\n';
std::cout << R"(
-----------------
| _______ ___ |
|| | | ||
|| _ | | ||
|| |_| | | ||
|| ___|__| ||
|| | | ||
||___| |_______||
-----------------
)" << '\n';
do
{
cout << "" << endl;
cout << "1.Albert" << endl;
cout << "2.Jon" << endl;
cout << "3.Ali" << endl;
cout << "4.PJ" << endl;
cout << "5.Exit" << endl;
cout << "Select Character:" << endl;
cin >> menu2;
system("cls");
if (menu2 == 1)
{
std::cout << R"(
Name: Albert Guerrero
Major: Marine Biology
Hobbies: Swimming, Water Polo, Surfing
Super Attack:
Tidal Wave - Summons a huge wave that
destroys any enemy in its path.
)" << '\n';
system("pause");
system("cls");
}
else if (menu2 == 2)
{
std::cout << R"(
Name: Jon Garcia
Major: Criminal Jsutice
Hobbies: ROTC, Hunting, Video Games
Super Attack:
Air Strike - Calls in a plane
that drops a wave of bombs.
)" << '\n';
system("pause");
system("cls");
}
else if (menu2 == 3)
{
std::cout << R"(
Name: Ali Miller
Major: Pre-Veterinary Medicine
Hobbies: Owl Watching, Reading, Hiking
Super Attack:
Parliament Call - Summons a large
group of owls that attacks her enemies.
)" << '\n';
system("pause");
system("cls");
}
else if (menu2 == 4)
{
std::cout << R"(
Name: PJ Izaguirre
Major: Exercise and Sports Science
Hobbies: Football, Running, Exercising
Super Attack:
Stampede - Calls forth the Universities
football team to stampede enemies nearby.
)" << '\n';
system("pause");
system("cls");
}
} while (menu2 != 5);
}
else if (menu == 3)
{
std::cout << R"(
-------------------------------------------------------
| _______ ______ _______ ______ ___ _______ _______ |
|| | _ | | | || | | ||
|| | | || | ___| _ | |_ _| _____||
|| | |_||_| |___| | | | | | | | |_____ |
|| _| __ | ___| |_| | | | | |_____ ||
|| |_| | | | |___| | | | | _____| ||
||_______|___| |_|_______|______||___| |___| |_______||
-------------------------------------------------------
)" << '\n';
cout << "" << endl;
std::cout << R"(
//enter info
)" << '\n';
system("pause");
system("cls");

}
} while (menu = !4);
return 0;
}
Last edited on
Your code is totally unreadable because you didn't put it between [code] [/code] tags.
I found an error: while (menu = !4); should rather be: while (menu != 4);. Because this the while evaluation part will always get evaluated to 'false'.
Last edited on
@dutch how do i put it in between tags?
First you type [code], then you re-copy and paste your code, then you type [/code].
So it's like this:

[code]
your
code
here
[/code]

Your usage of raw strings just means you don't need to type \n at the end of the lines, which is poor compensation for not being able to properly indent those blocks.

I think the following is better. Notice how you can split a long string over multiple lines by typing an end quote and then a beginning quote on the next line. The seemingly separate strings will be concatenated together into one long string at compile time.

1
2
3
4
5
6
7
8
9
10
                if (menu2 == 1)
                {
                    std::cout << 
                        "Name: Albert Guerrero\n"
                        "Major: Marine Biology\n"
                        "Hobbies: Swimming, Water Polo, Surfing\n"
                        "Super Attack: \n"
                        "Tidal Wave - Summons a huge wave that\n"
                        "destroys any enemy in its path.\n\n";
                }

Last edited on
dutch how did you write code tags without having it being parsed? ;-;
Teach me your ways master. Please.

edit:
[code]Hello[/code]
Ahh I inspected and saw that you inserted bold tags inside the code tag: [co[b.][/b]de][/code]
Intelligent!

This doesn't work tho:
[co[b[i][/i]][/b]de][/code]
Awww

tezting:
[code][/code]
[output][/output]
[quote][/quote]
[b[b][/b]][/b]
[i[b][/b]][/i]
[u[b][/b]][/u]
[center][/center]
[s[b][/b]][/s]
[tt][/tt]
[small][/small]
[sub][/sub]
[sup][/sup]

Ah so it works with tags that have at least two characters. Cool.

[quote][output][code][/code][/output][/quote]
Last edited on
It looks like you figured it out. I did the same thing with one of salemc's post, looking at the page source and seeing the bold tags. Alternatively you can put bold tags around [code] like this [code] [/code], or teletype tags like this [code] [/code].

The teletype tags work around the bold tag, too: [b] [/b]

Really there should be a general tag for this purpose that says "don't parse what's inside these tags", something like

[noparse] whatever [/noparse]
Last edited on
Topic archived. No new replies allowed.