• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            逛奔的蝸牛

            我不聰明,但我會很努力

               ::  :: 新隨筆 ::  ::  :: 管理 ::
            #include <iostream>
            #include 
            <conio.h>

            /**
             * 秘密在于conio.h中的getch()從鍵盤中讀取字符時,并不會在屏幕上輸出已經(jīng)輸入的字符,
             * 而用一個putch('*')來哄騙,代表已經(jīng)輸入一個字符
             * 怪不得這個頭文件要叫conio.h, con的意思就有哄騙,看來就是由此而來.
             
            */

            using namespace std;

            int main() {
                    
            char* password;
                    
            char* passwordConfirm;

                    
            int length = 4;
                    password 
            = new char[length + 1];
                    passwordConfirm 
            = new char[length + 1];

                    
            char* p = NULL;
                    
            int count = 0;

                    cout 
            << "Input password : ";
                    p 
            = password;
                    count 
            = 0;
                    
            //fflush(stdin);
                    while (((*= getch()) != 13&& count < length) {
                            
            // 這里不是'\n'(10), new line
                            
            // 而是'\r'(13), reback. 即是按下回車鍵,好像這個東西是linux的.
                            
            // 主要是與getch這個函數(shù)有關(guān).
                            putch('*');
                            fflush(stdin);

                            p
            ++;
                            count
            ++;
                    }
                    password[count] 
            = '\0';

                    cout 
            << endl << "Confirm the password : ";
                    p 
            = passwordConfirm;
                    count 
            = 0;
                    
            //fflush(stdin);
                    while (((*= getch()) != 13&& count < length) {
                            putch(
            '*');
                            fflush(stdin);

                            p
            ++;
                            count
            ++;
                    }
                    passwordConfirm[count] 
            = '\0';

                    cout 
            << endl;
                    
            if (strcmp(password, passwordConfirm) == 0) {
                            cout 
            << "The password is right." << endl;
                            cout 
            << password << endl;
                    } 
            else {
                            cout 
            << "Confirm password fail." << endl;
                            cout 
            << password << endl << passwordConfirm << endl;
                    }

                    
            return 0;
            }










            posted on 2008-04-12 03:32 逛奔的蝸牛 閱讀(764) 評論(1)  編輯 收藏 引用 所屬分類: C/C++

            評論

            # re: 控制臺輸入密碼, 用*號掩藏 2008-04-12 09:18 大海
            要是用戶按回退鍵怎末顯示呀  回復(fù)  更多評論
              

            亚洲国产精品成人久久蜜臀 | 午夜人妻久久久久久久久| 亚洲日韩欧美一区久久久久我| 久久青青草视频| 久久强奷乱码老熟女网站| 久久妇女高潮几次MBA| 国产精品久久久天天影视| 久久91精品综合国产首页| 国产精品久久国产精麻豆99网站| segui久久国产精品| 久久乐国产综合亚洲精品| 国产韩国精品一区二区三区久久| 久久国产成人午夜aⅴ影院| 久久天天躁狠狠躁夜夜96流白浆| 亚洲国产精品久久久久久| 国产69精品久久久久APP下载| 久久99国产综合精品女同| 欧美国产精品久久高清| 国产精品久久久久影院嫩草| 久久精品国产99久久久古代 | 伊人久久大香线蕉综合网站| 国产91色综合久久免费| 色8激情欧美成人久久综合电| 久久国产高清字幕中文| 亚洲欧美另类日本久久国产真实乱对白| 麻豆亚洲AV永久无码精品久久| 中文字幕无码久久人妻| 久久亚洲2019中文字幕| 国产午夜精品久久久久九九电影| A狠狠久久蜜臀婷色中文网| 亚洲中文字幕无码久久2017| 日日狠狠久久偷偷色综合96蜜桃| 国产综合精品久久亚洲| 99久久99久久精品国产| 久久久国产精品福利免费| 国产精品成人久久久| 久久国产综合精品五月天| 国产精品狼人久久久久影院| 久久久久久久综合日本| 三级片免费观看久久| 思思久久99热只有频精品66|