开发者

What's wrong with my code? (pdcurses/getmaxyx)

It gives me an access violation on the getmaxyx line (second line in the main function) and also gives me these two warnings:

LINK : warning LNK4049: locally defined symbol "_stdscr" imported
LINK : warning LNK4049: locally defined symbol "_SP" imported

Yes, it's the same code as in another question I asked, it's just that I'm making it more clear. And yes, I have written programs with pdcurses before with no problems.

#include <time.h>
#include <curses.h>
#include "Ball.h"
#include "Paddle.h"
#include "config.h"

int main(int开发者_运维技巧 argc, char *argv[])
{
    int maxY, maxX;
    getmaxyx(stdscr, maxY, maxX);

    Paddle *paddleLeft = new Paddle(0, KEY_L_UP, KEY_L_DOWN);
    Paddle *paddleRight = new Paddle(maxX, KEY_R_UP, KEY_R_DOWN);
    Ball *ball = new Ball(paddleLeft, paddleRight);

    int key = 0;

    initscr();
    cbreak();
    noecho();
    curs_set(0);

    while (key != KEY_QUIT)
    {
        key = getch();
        paddleLeft->OnKeyPress(key);
        paddleRight->OnKeyPress(key);
    }

    endwin();
    return 0;
}


It has been a long time since I have used curses, but I would guess you need to call initscr() before any other curses call like getmaxyx.

Also, you probably are also missing some error checking on the return of initscr and need to use the return values properly (perhaps you have to pass it on to other curses method?).


You need to call initscr before getmaxyx

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜