Skip to main content
edited tags
Link
200_success
  • 145.7k
  • 22
  • 191
  • 481
deleted 69 characters in body; edited title
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

Creating a border using ncurses in c++

The biggest question is if it's worth it to use a useless ifif statement to make the xx and yy variables local away from the main statement.

        //Unconventional part, make it so that x and y are local variables
    if(true){
            int x,y;
            //set x and y to be the width + height of the terminal
            getmaxyx(stdscr,y,x);
            for(int i = 0; i < x; i++){
                    //top border
                    mvaddch(0,i,'#');
                    //bottom border
                    mvaddch(y - 1,i,'#');
            }
            for(int i = 0; i < y; i++){
                    //left border
                    mvaddch(i,0,'#');
                    //right border
                    mvaddch(i,x - 1,'#');
            }
    }

Creating a border using ncurses in c++

The biggest question is if it's worth it to use a useless if statement to make the x and y variables local away from the main statement.

        //Unconventional part, make it so that x and y are local variables
    if(true){
            int x,y;
            //set x and y to be the width + height of the terminal
            getmaxyx(stdscr,y,x);
            for(int i = 0; i < x; i++){
                    //top border
                    mvaddch(0,i,'#');
                    //bottom border
                    mvaddch(y - 1,i,'#');
            }
            for(int i = 0; i < y; i++){
                    //left border
                    mvaddch(i,0,'#');
                    //right border
                    mvaddch(i,x - 1,'#');
            }
    }

Creating a border using ncurses

The biggest question is if it's worth it to use a useless if statement to make the x and y variables local away from the main statement.

    //Unconventional part, make it so that x and y are local variables
if(true){
        int x,y;
        //set x and y to be the width + height of the terminal
        getmaxyx(stdscr,y,x);
        for(int i = 0; i < x; i++){
                //top border
                mvaddch(0,i,'#');
                //bottom border
                mvaddch(y - 1,i,'#');
        }
        for(int i = 0; i < y; i++){
                //left border
                mvaddch(i,0,'#');
                //right border
                mvaddch(i,x - 1,'#');
        }
}
Source Link
Alex
  • 143
  • 3

Creating a border using ncurses in c++

The biggest question is if it's worth it to use a useless if statement to make the x and y variables local away from the main statement.

        //Unconventional part, make it so that x and y are local variables
    if(true){
            int x,y;
            //set x and y to be the width + height of the terminal
            getmaxyx(stdscr,y,x);
            for(int i = 0; i < x; i++){
                    //top border
                    mvaddch(0,i,'#');
                    //bottom border
                    mvaddch(y - 1,i,'#');
            }
            for(int i = 0; i < y; i++){
                    //left border
                    mvaddch(i,0,'#');
                    //right border
                    mvaddch(i,x - 1,'#');
            }
    }