[問題] 請問輸入密碼時,用*呈現的寫法?
開發平台(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
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
12/08 00:56, 4F
→
12/08 01:18, , 5F
12/08 01:18, 5F
→
12/08 01:20, , 6F
12/08 01:20, 6F