#How to make square border using _ and |

18 messages · Page 1 of 1 (latest)

ionic spoke
#
{
    for (int i = 0; i < height; i++)
    {
        cout << "\t\t|";
        for (int j = 0; j < width - 2; j++)
        {
            if (i == 0)
                cout << "_";
            else if (i == height - 1)
                cout << "_";
            else
                cout << " ";
        }
        cout << "|" << endl;
    }
}```
I was wondering how I could make an exact border because when I try to move the width it just disappears
this is the output:
versed vaporBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

fierce minnow
ionic spoke
#

I dont wanna get the size of rows and columns. I just wanna know how I can move the width on top so the height doesn't overlap

fierce minnow
#

what does " try to move the width it just disappears" mean

#

you're asking for the border top to be higher? just put it one line higher then

#

I don't think there's an ascii character for opposite of _

#

you can also print unicode instead ‾

ionic spoke
#

i tried it using the unicode

ionic spoke
#
using namespace std;

const int width = 50;
const int height = 25;

void screen()
{
    for (int i = 0; i < height; i++)
    {
        cout << "\t\t|";
        for (int j = 0; j < width - 2; j++)
        {
            if (i == 0 - 1)
                cout << "_";
            else if (i == height - 1)
                cout << "_";
            else
                cout << " ";
        }
        cout << "|" << endl;
    }
}

int main()
{
    screen();
    return 0;
}```
fierce minnow
#

well 0 - 1 will never be true

#

just go with the unicode approach, simpler logic

ionic spoke
#

!solved