under linux c ++ how to input does not echo

#include <stdio.h>
#include <termios.h> 
#include <unistd.h> #include <iostream> using namespace std; int main(void){ char c; static struct termios oldt, newt; tcgetattr( STDIN_FILENO, &oldt); newt = oldt; newt.c_lflag &= ~(ICANON); tcsetattr( STDIN_FILENO, TCSANOW, &newt); system("stty -echo"); while((c=getchar())!= 'e') { char d = c + 'A' - 'a'; cout << d << endl; } system("stty echo"); tcsetattr( STDIN_FILENO, TCSANOW, &oldt); return 0;
}

Wherein execution of the code between system ( "stty -echo") and the system ( "stty echo") will not be echoed

 

Guess you like

Origin www.cnblogs.com/qiumingcheng/p/11461341.html