2010-08-01 133 views
1
#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變交流-lcurses -o一getyx返回-1 -1

X = -1,Y = -1

爲什麼?

回答

4

也許你應該在試圖使用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/

+0

請舉例... – tt123 2010-08-01 14:16:03