开发者

getyx return -1 -1

开发者 https://www.devze.com 2023-01-09 14:21 出处:网络
#include <stdio.h> #include <curses.开发者_如何转开发h> int main () { int y, x; getyx( curscr, y, x);
#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

Why?


Maybe you should call initscr(); before trying to use curses ?

#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;
}

You'll find that reading at least some of the documentation for a programming library is time well invested, e.g. http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号