Printing borders outside words? help?

Have images of string letters intitialized
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
const string letters[46][5]=
{
	{				
"   _____   ",						
"  /  _  \\  ",
" /  /_\\  \\ ",
"/    |    \\",
"\\____|__  /" },


{"__________ ",
"\\______   \\",
 "|    |  _//",
" |    |   \\",
" |______  //"},



Moreover, I have this function that will print out the horizontal line. As i'm trying to print out the top horizontal line of the border, all I get is justa small "__." The user length of string is 2 and i'm sure it did perform that, but how can I perform it in such a way that it will print out a length more then sentence.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
void printoutusersentencebordertype (string &usertypes)
{
	{
	
	
	
	//User types in a sentence
	cout<<"\n\n\t\tMessage: ";
	cin>>usertypes;

	//Make a top left border;
	cout<<"\n\n\n";
	cout<<(char)(218);

	
	//Print a horizontal line
	for (int tot_len_hor=0;tot_len_hor<usertypes.length();tot_len_hor++)
	{
		cout<<(char)(196);//Print horizontal line
		//If index is one lower then the total length then print out vertical bar
			if (tot_len_hor=(usertypes.length())-1);
			{
				//print a vertical bar
				cout<<(char)(191);
			}
	
	}
	

My problem is i'm getting a small length of the horizontal line.

also the program objective is to have a border around the words.
Last edited on
This:
if (tot_len_hor=(usertypes.length())-1);
should use "==" instead of "=".

As currently written, the code assigns usertypes.length()-1 to tot_len_hor. Since this value is non-zero (unless you entered a one-character string), it evaluates to "true" and you get the horizontal bar. The second time through the "for" loop tot_len_hoz gets incremented and the test fails, so the "for" loop exits.
dhayden nice find. Thanks! however I still can't seem to figure out how to print out a horizontal line that can get accustomed to the length of this
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
const string letters[46][5]=
{
	{				
"   _____   ",						
"  /  _  \\  ",
" /  /_\\  \\ ",
"/    |    \\",
"\\____|__  /" },


{"__________ ",
"\\______   \\",
 "|    |  _//",
" |    |   \\",
" |______  //"},
Topic archived. No new replies allowed.