-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpassword.c
57 lines (45 loc) · 955 Bytes
/
password.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include<stdio.h>
#include<string.h>
#include<conio.h>
int main(){
int passwordlength=20;
char password[passwordlength+1];
char ch;
int charposition=0;
printf("enter your password maximum pasword length is 20");
while(1){
ch=getch();
if(ch==13){
break;
}
if(ch==8){
if (charposition>0){
charposition--;
printf("\b") ;
ch=NULL;
printf("%c",ch);
printf("\b");
continue;
}
}
if(ch==32||ch==9){
continue;
}
if(charposition<passwordlength){
password[charposition]=ch;
charposition++;
printf("*");
}
else{
printf("yourpassword exceeds maximum length");
break;
}
}
password[charposition]='\0';
printf("\n");
if(strlen(password)==0){
printf("no password entered");
}
printf("your password is %s",password);
return 0;
}