Creating a box with lines outside the menu

Hi, I'm trying to create a menu and I want it to be inside some lines so it looks cool, but how do I do it? I know the for loop would be great for it, but I don't know how to set it up.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
void menu()
{
	cout << "\n Hi! Welcome to \'The X\'.\n\n";
	cout << "\n\n\t\t  MENU\n";
	cout << "\t-----------------------\n";
	cout << "  Apples \t   Cheese \t   Bread\n";
	cout << " -------" << "          --------";
	cout << "\n$2.5 each \t$2 per pound \t$3 per loaf";

}


void outer_lines_menu()
{
	for (int x = 0; x < 10; x++)
		cout << "\|" << endl;

}


And of course the top part of the box instead of like this: | it would be like this: _ . So how would it be? :\

This is my first course in college :)
Last edited on
If the contents of the menu are statically known (we know what the menu contains at the time we write the code), a raw string literal would suffice.
http://www.stroustrup.com/C++11FAQ.html#raw-strings

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>

void menu()
{
    std::cout << R"(
        Hi! Welcome to 'the X'
                       MENU
        -------------------------------------
        |                                   |
        |     1. Apples $2.50 each          |
        |                                   |
        |     2. Cheese $2.00 per pound     |
        |                                   |
        |     3. Bread  $3.00 per loaf      |
        |                                   |
        -------------------------------------
       )" ;
}

http://coliru.stacked-crooked.com/a/9900d0a34ae324fa
Thank you!
Topic archived. No new replies allowed.