Reputation: 153
For some reason my noecho()
initialization is not working, until I give an input twice. The first time I press h
, I get an 'h'
char on the screen. However, next pressed keys don't appear on the screen. How can I prevent ALL input from showing?
#include <ncurses.h>
int main(){
initscr(); /* Start curses mode */
raw(); /* prevents use of signals from ctl + c
noecho(); /* suppress echo */
mvprintw(10,10,"Hello World!!"); /* Print */
refresh(); /* print it on real screen */
while(true){
char ch = getch(); /* wait for input */
if(ch == 'q')
break;
else if(ch == 'h'){
mvprintw(10,10,"Test");
}
else{
attroff(A_BOLD);
}
}
endwin(); /* end curses mode */
return 0;
}
Upvotes: 0
Views: 1552
Reputation: 54563
The comment is un-ended, making the compiler ignore noecho
:
raw(); /* prevents use of signals from ctl + c
noecho(); /* suppress echo */
You can see this if you use gcc's warnings:
foo.c:3:5: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
foo.c: In function ‘main’:
foo.c:6:37: warning: "/*" within comment [-Wcomment]
foo.c:12:23: warning: conversion to ‘char’ from ‘int’ may alter its value [-Wconversion]
Upvotes: 1