I am trying to make a simple console program using curses on ubuntu, but each time I try to call getch and make it wait for input, when I input the input, it throws a segmentation fault. I did initialize the library using the initscr() function in another part of my code.
Here is the part of code throwing the segmentation fault :
int ch;
ch = getch();
Any help is greatly appreciated,
Mindoo
EDIT: After switching out the int for a char, I get the following warnings that revolve arround this piece of code right after the previously mentioned getch().
char ch;
ch = getch();
//Get xObject position
int xObjectX = getXObject()->getPosX();
int xObjectY = getXObject()->getPosY();
switch (ch) {
case KEY_LEFT:
getXObject()->move(xObjectY, xObjectX--);
break;
case KEY_RIGHT:
getXObject()->move(xObjectY, xObjectX++);
break;
case KEY_UP:
getXObject()->move(xObjectY++, xObjectX);
break;
case KEY_DOWN:
getXObject()->move(xObjectY--, xObjectX);
break;
case KEY_BACKSPACE:
game->stop();
break;
I get these warnings :
TestGameState.cpp: In member function ‘virtual void TestGameState::handleInput()’:
TestGameState.cpp:21:5: warning: case label value exceeds maximum value for type
case KEY_LEFT:
^
TestGameState.cpp:25:5: warning: case label value exceeds maximum value for type
case KEY_RIGHT:
^
TestGameState.cpp:29:5: warning: case label value exceeds maximum value for type
case KEY_UP:
^
TestGameState.cpp:33:5: warning: case label value exceeds maximum value for type
case KEY_DOWN:
^
TestGameState.cpp:37:5: warning: case label value exceeds maximum value for type
case KEY_BACKSPACE: