border

Write your question here.
I want to create a border for my program, but I don't know how to. I am a beginner. Thanks.
1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
#include <string>
using namespace std;

int main()
{
  string name;
  cout << "What is your name? \n";
  getline (cin, name);
  cout << "Merry Christmas,  " << name << "!\n";
}
Last edited on
One step at a time.
First create a left and right border to the output line. Simple example,
the line starts like this:
"Merry Christmas, Joe!"
add left and right
"* Merry Christmas, Joe! *"

If you first store that in a string, it is easy enough to find the length, using string.size().

Now you can create a top and bottom border by making a string like this "****" with the same length. See option 6 on this page, ' Fills the string with n consecutive copies of character c.
http://www.cplusplus.com/reference/string/string/string/

Finally output these strings to give the finished result.
Last edited on
Topic archived. No new replies allowed.