'How can I make a rectangle with text in the center in C++?
I'm a beginner and I'm currently learning how to make a simple graphic for a program that will make a rectangle and it has text inside and it can receive a user input. But I do not know how to put the text inside the rectangle.
Here is the code that I used
int Menu() {
int userInput;
{
for (int column = 0; column < 80; ++column)
{
cout << "*";
}
cout << "\n";
for (int row = 0; row < 8; ++row)
{
cout << "*";
for (int column = 0; column < 78; ++column)
{
cout << " ";
}
cout << "*\n";
}
for (int column = 0; column < 80; ++column)
{
cout << "*";
}
cout << "\n";
}
cout << "\n--------------------------------------------";
cout << "\n\t CONVERTER MENU";
cout << "\n--------------------------------------------";
cout << "\n1. Convert Decimal";
cout << "\n2. Convert Binary";
cout << "\n3. Convert Octal";
cout << "\n4. Convert HexaDecimal";
cout << "\n5. Exit Converter";
cout << "\n--------------------------------------------";
cout << "\n Enter the number of your choice: ";
cin >> userInput;
return userInput;
}
Here is the output of my code

****************************
* *
* *
* *
****************************
Text right here:
Here's how I want the output to be
****************************
* *
* Text right here: *
* *
****************************
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
