Skip to main content
Minor changes
Source Link
Chris Davies
  • 128.4k
  • 16
  • 179
  • 324

The problem is that you're using literal characters , , , , , instead of using the ncurses-independent symbols. You should use the ACS_??CORNER (for Upper/Lower and Left/Right) valuesand ACS_HLINE symbolic names and let ncurses work out how to represent those on your terminal.

Modifying your code from this,

mvprintw(0,0,"┏━┓");
mvprintw(1,0,"┗━┛");

Toto this,

move(0,0); addch(ACS_ULCORNER); addch(ACS_HLINE); addch(ACS_URCORNER);
move(1,0); addch(ACS_LLCORNER); addch(ACS_HLINE); addch(ACS_LRCORNER);

should ensure that the code works portably. I also changed the end of your main() procedure from a plain return 0 to thisthe following, so that the terminal couldwill be correctly reset when the program ends:

endwin();
exit(0);

Compile test.cpp and execute with,

LDLIBS=-lncurses make test && ./test

Useful references, in no particular order:

The problem is that you're using literal characters , , , instead of using the ncurses-independent symbols. You should use the ACS_??CORNER (for Upper/Lower and Left/Right) values and let ncurses work out how to represent those on your terminal.

Modifying your code from this,

mvprintw(0,0,"┏━┓");
mvprintw(1,0,"┗━┛");

To this,

move(0,0); addch(ACS_ULCORNER); addch(ACS_HLINE); addch(ACS_URCORNER);
move(1,0); addch(ACS_LLCORNER); addch(ACS_HLINE); addch(ACS_LRCORNER);

should ensure that the code works portably. I also changed the end of your main() procedure from a plain return 0 to this, so that the terminal could be correctly reset:

endwin();
exit(0);

Compile and execute with,

LDLIBS=-lncurses make test && ./test

Useful references, in no particular order:

The problem is that you're using literal characters , , , , , instead of using the ncurses-independent symbols. You should use the ACS_??CORNER (for Upper/Lower and Left/Right) and ACS_HLINE symbolic names and let ncurses work out how to represent those on your terminal.

Modifying your code from this,

mvprintw(0,0,"┏━┓");
mvprintw(1,0,"┗━┛");

to this,

move(0,0); addch(ACS_ULCORNER); addch(ACS_HLINE); addch(ACS_URCORNER);
move(1,0); addch(ACS_LLCORNER); addch(ACS_HLINE); addch(ACS_LRCORNER);

should ensure that the code works portably. I also changed the end of your main() procedure from a plain return 0 to the following, so that the terminal will be correctly reset when the program ends:

endwin();
exit(0);

Compile test.cpp and execute with,

LDLIBS=-lncurses make test && ./test

Useful references, in no particular order:

Realised that the square is 3x2 not 2x2
Source Link
Chris Davies
  • 128.4k
  • 16
  • 179
  • 324

The problem is that you're using literal characters , , , instead of using the ncurses-independent symbols. You should use the ACS_??CORNER (for Upper/Lower and Left/Right) values and let ncurses work out how to represent those on your terminal.

Modifying your code from this,

mvprintw(0,0,"┏━┓");
mvprintw(1,0,"┗━┛");

To this,

move(0,0); addch(ACS_ULCORNER); addch(ACS_HLINE); addch(ACS_URCORNER);
move(1,0); addch(ACS_LLCORNER); addch(ACS_HLINE); addch(ACS_LRCORNER);

should ensure that the code works portably. I also changed the end of your main() procedure from a plain return 0 to this, so that the terminal could be correctly reset:

endwin();
exit(0);

Compile and execute with,

LDLIBS=-lncurses make test && ./test

Useful references, in no particular order:

The problem is that you're using literal characters , , , instead of using the ncurses-independent symbols. You should use the ACS_??CORNER (for Upper/Lower and Left/Right) values and let ncurses work out how to represent those on your terminal.

Modifying your code from this,

mvprintw(0,0,"┏━┓");
mvprintw(1,0,"┗━┛");

To this,

move(0,0); addch(ACS_ULCORNER); addch(ACS_URCORNER);
move(1,0); addch(ACS_LLCORNER); addch(ACS_LRCORNER);

should ensure that the code works portably. I also changed the end of your main() procedure from a plain return 0 to this, so that the terminal could be correctly reset:

endwin();
exit(0);

Useful references, in no particular order:

The problem is that you're using literal characters , , , instead of using the ncurses-independent symbols. You should use the ACS_??CORNER (for Upper/Lower and Left/Right) values and let ncurses work out how to represent those on your terminal.

Modifying your code from this,

mvprintw(0,0,"┏━┓");
mvprintw(1,0,"┗━┛");

To this,

move(0,0); addch(ACS_ULCORNER); addch(ACS_HLINE); addch(ACS_URCORNER);
move(1,0); addch(ACS_LLCORNER); addch(ACS_HLINE); addch(ACS_LRCORNER);

should ensure that the code works portably. I also changed the end of your main() procedure from a plain return 0 to this, so that the terminal could be correctly reset:

endwin();
exit(0);

Compile and execute with,

LDLIBS=-lncurses make test && ./test

Useful references, in no particular order:

Source Link
Chris Davies
  • 128.4k
  • 16
  • 179
  • 324

The problem is that you're using literal characters , , , instead of using the ncurses-independent symbols. You should use the ACS_??CORNER (for Upper/Lower and Left/Right) values and let ncurses work out how to represent those on your terminal.

Modifying your code from this,

mvprintw(0,0,"┏━┓");
mvprintw(1,0,"┗━┛");

To this,

move(0,0); addch(ACS_ULCORNER); addch(ACS_URCORNER);
move(1,0); addch(ACS_LLCORNER); addch(ACS_LRCORNER);

should ensure that the code works portably. I also changed the end of your main() procedure from a plain return 0 to this, so that the terminal could be correctly reset:

endwin();
exit(0);

Useful references, in no particular order: