I am currently building Tetris on the command line, and I'm working with getch()
to recieve input without a deliminating character and without pausing the code to take input. However, when I enable the function with initscr()
, all my output is lost.
#include <ncurses.h>
#include <iostream>
using std::cout;
using std::endl;
//created variables, set up, etc etc
int main(){
initscr();
cbreak();
keypad(stdscr, TRUE);
noecho();
while (true){
cout << "hello" << endl; //complex things are printed here
int input;
while (true){
input = getch();
if (input == -1){
break;
} else {
return 1; //my initial goal was just to get getch() to work, so the input reponse is to end the program
}
}
cout << "goodbye" << endl; //other complex things are printed here
}
return 0;
}
Without initscr()
turned on, all my output printed (but getch()
didn't work). With it, I get a blank screen. Why is this happening, and how can I fix it?
Aucun commentaire:
Enregistrer un commentaire