Is there any reason why printw() would cause a segmentation fault?
Code is fine without it; broken with it. It doesn’t seem to be doing anything esoteric, so I’m not sure how to even begin to understand what is wrong here.
Thanks in advance for any advice!
#include <ncurses.h>
...
initscr();
noecho();
cbreak();
...
void draw_court()
{
move(TOP_ROW-1, LEFT_COL+4);
printw("LIVES REMAINING: 3");
int i;
for (i = 0; i < RIGHT_COL; i++)
mvaddch(TOP_ROW, LEFT_COL+i, H_LINE);
for (i = 1; i < BOT_ROW-TOP_ROW; i++)
mvaddch(TOP_ROW+i, LEFT_COL, V_LINE);
for (i = 0; i < RIGHT_COL; i++)
mvaddch(BOT_ROW, LEFT_COL+i, H_LINE);
}
ETA: The stacktrace from gdb:
#0 0xb778a139 in _nc_printf_string () from /lib/libncurses.so.5
#1 0xb7785e04 in vwprintw () from /lib/libncurses.so.5
#2 0xb7785f63 in printw () from /lib/libncruses.so.5
#3 0x08048f23 in draw_court ()
#4 0x080489f4 in set_up ()
#5 0x0804890a in main ()
Did you forget to call initscr()?