我怀疑您正试图在窗口范围之外打印。
特别是,我想在这里:
mvwprintw(results_scrn,num_rows_res,(num_col_res/2) - 2,"Close");
...num_rows_res
是results_scrn
窗口中的行数 - 但这意味着有效的行坐标范围从0
到num_rows_res - 1
。
如果您尝试移出move()
或wmove()
移出窗口,则光标实际上不会移动;随后的printw()
orwprintw()
将在前一个光标位置打印。如果您尝试使用mvprintw()
or mvwprintw()
,则整个调用将在尝试移动光标时失败,因此它根本不会打印任何内容。
这是一个完整的演示(仅打印stdscr
具有LINES
行和COLS
列的内容):
#include <stdio.h>
#include <curses.h>
int main(void)
{
int ch;
initscr();
noecho();
cbreak();
/* This succeeds: */
mvprintw(1, 1, ">>>");
/* This tries to move outside the window, and fails before printing: */
mvprintw(LINES, COLS / 2, "doesn't print at all");
/* This tries to move outside the window, and fails: */
move(LINES, COLS / 2);
/* This prints at the cursor (which hasn't successfully moved yet): */
printw("prints at current cursor");
/* This is inside the window, and works: */
mvprintw(LINES - 1, COLS / 2, "prints at bottom of screen");
refresh();
ch = getch();
endwin();
return 0;
}
(事实上,这些函数确实会返回一个结果;如果你检查它,你会发现它是ERR
在失败的情况下。)