c++ - ncurses getch() weird output? -
i have installed ncurses.h lib , started experimenting getch() function.when built , run code seems alright me @ first, console printed out weird character: '�'(if doesn't show , shows space here screen shot: https://prnt.sc/gbrp7b) console starts spamming if type character, shows in output still '�' spams. here code:
#include <iostream> #include <fstream> #include <ncurses.h> using namespace std; int main(){ char input; while(true){ input = getch(); cout << "you entered : " << input << endl; //break; } return 0; }
so thought of trying use if statement try , stop spamming code doesn't recognise character:
it gives error:
error: character large enclosing character literal type
for code:
#include <iostream> #include <fstream> #include <ncurses.h> using namespace std; int main(){ char input; while(true){ input = getch(); if(input!='�'){ cout << "you entered : " << input << endl; } } return 0; }
i on osx sierra 10.12.5 , using eclipse oxygen
you need initialize ncurses
initscr()
, close endwin()
functions:
#include <iostream> #include <fstream> #include <ncurses.h> using namespace std; int main(){ char input; initscr(); while (true) { input = getch(); cout << "you entered : " << input << endl; } endwin(); return 0; }
wiki
Comments
Post a Comment