重複の可能性:
端末でのパスワード入力を非表示にする
私はこれを達成したい:
$Insert Pass:
User types: a (a immediately disappears & '*' takes its position on the shell)
On the Shell : a
Intermediate O/P: *
User types: b (b immediately disappears & '*' takes its position on the shell)
On the Shell : *b
Intermediate O/P: **
User types: c (c immediately disappears & '*' takes its position on the shell)
On the Shell : **c
Final O/P : ***
私は次のアプローチを試しました:
#include <stdio.h>
#include <string.h>
#define SIZE 20
int main()
{
char array[SIZE];
int counter = 0;
memset(array,'0',SIZE);
while ((array[counter]!='\n')&&(counter<=SIZE-2))
{
array[counter++] = getchar();
printf("\b\b");
printf ("*");
}
printf("\nPassword: %s\n", array);
return 0;
}
しかし、期待した成果を達成することができません。このコードでは、ユーザー入力文字を非表示にして「*」をすぐに表示することはできません。
誰かがこれについて私を案内してくれませんか。
ありがとう。
よろしく、Sandeep Singh