#include <stdio.h>
#include <curses.h>
int main () {
int y, x;
getyx( curscr, y, x);
printf("x=%i, y=%i", x, y);
return 0; }
gcc a.c -lcurses -o a
x=-1, y=-1
为什么?
最佳答案
也许您应该在尝试使用 curses 之前调用 initscr();
?
#include <stdio.h>
#include <curses.h>
int main (void)
{
int y = 0, x = 0;
initscr();
getyx(curscr, y, x);
printw("x = %d, y = %d", x, y);
refresh();
getchar();
endwin();
return 0;
}
您会发现至少阅读编程库的一些文档是值得投入时间的,例如http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/
关于c - getyx 返回 -1 -1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3382306/