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,'#');
}
}
if(true)could be left out \$\endgroup\$if. I agree that I'd make it a function \$\endgroup\$