문제

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top