mac c++ 如何输入时不回显

 string string_encrypt(){
        string cin_line;
        struct termios org_opts{};
        struct termios new_opts{};
        tcgetattr(STDIN_FILENO,&org_opts);
        memcpy(&new_opts, &org_opts, sizeof(org_opts));
        new_opts.c_lflag &=~(ECHO | ECHOE );
        tcsetattr(STDIN_FILENO, TCSANOW, &new_opts);
        getline(std::cin, cin_line);
        tcsetattr(STDIN_FILENO,TCSANOW, &org_opts);
        return cin_line;
    }

你可能感兴趣的:(mac c++ 如何输入时不回显)