建议的答案有几个问题:
这是一个更正的版本:
#include <curses.h>
int main (void) {
int i;
WINDOW *w;
w = initscr();
scrollok(w, 1);
wsetscrreg(w, 4, LINES-1);
wprintw(w, "%s\n", "Info 1");
wprintw(w, "%s\n", "Info 2");
wprintw(w, "%s\n", "Info 3");
wprintw(w, "%s\n", "Info 4");
wrefresh(w);
i = 0;
while (++i) {
wprintw(w, "%d\n", i);
wrefresh(w);
}
endwin();
return 0;
}
此外,意识到返回值initscr
是stdscr
,程序可以简化:
#include <curses.h>
int main (void) {
int i;
initscr();
scrollok(stdscr, 1);
setscrreg(4, LINES-1);
printw("%s\n", "Info 1");
printw("%s\n", "Info 2");
printw("%s\n", "Info 3");
printw("%s\n", "Info 4");
refresh();
i = 0;
while (++i) {
printw("%d\n", i);
refresh();
}
endwin();
return 0;
}