[問題] 請問輸入密碼時,用*呈現的寫法?

看板C_and_CPP作者 (千里之外)時間12年前 (2011/12/07 17:54), 編輯推噓1(105)
留言6則, 5人參與, 最新討論串1/1
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) dev-c 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) 問題(Question): 我的寫法... #include <stdio.h> #include <stdlib.h> #include <conio.h> #include <string.h> #define ENTER 13 int main(void){ char pass[10]; char pass1[10]; char ch; int i=0; printf("請輸入密碼: "); while((ch=getch())!= ENTER){ putchar('*'); //完成星號輸出 pass1[i++]=ch; } pass1[i]='\0'; printf("\n\n=====驗証中=======\n"); if(strcmp(pass,pass1)==0){ printf("密碼輸入正確!!\n"); } else printf("輸入錯誤!!\n"); system("pause"); return 0; } 感覺寫法並不好...加上linuxc若沒有getch()函數的話... 怎麼寫呢?? 餵入的資料(Input): 預期的正確結果(Expected Output): 錯誤結果(Wrong Output): 程式碼(Code):(請善用置底文網頁, 記得排版) 補充說明(Supplement): -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.26.127.117

12/07 18:02, , 1F
google "getch linux"
12/07 18:02, 1F

12/07 20:40, , 2F
組語寫起來還滿簡單的@@
12/07 20:40, 2F

12/07 23:39, , 3F
請先去爬一下文......
12/07 23:39, 3F

12/08 00:56, , 4F
tcsetattr tcgetattr termios 找看看這幾個關鍵字
12/08 00:56, 4F

12/08 01:18, , 5F
還有cfmakeraw
12/08 01:18, 5F

12/08 01:20, , 6F
嗯.. 我沒看標題XD 只看到getch()
12/08 01:20, 6F
文章代碼(AID): #1EtpV2MF (C_and_CPP)