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.
void printoutusersentencebordertype (string &usertypes)
//User types in a sentence
//Make a top left border;
//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
//print a vertical bar
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.
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.