我懷疑你正試圖將窗口的邊界之外打印的一部分。
特別,我猜這裏:
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()
或wprintw()
將在前一個光標位置打印。如果您嘗試使用mvprintw()
或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
在失敗的情況下)