Skip to main content

C Program for Password Login IN CUI

 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
#include <stdio.h>
char str;
char passwd[100];
void main()
{

    int i=0,j;
    printf("Enter the text now \n");
            while((str=getch())!='\r')
            {
                    if (str=='\b'){ // if a backspace key is used then go back
                    printf("\b \b");
                    i--;
                }
            else{
                    passwd[i++]=str;
                    printf("*"); // hide the password
                }
            }


    printf("\nFinished ");

    printf("\nYour password is ->");
    for( j=0;j<i;j++)
        printf("%c",passwd[j]);
    getch();
}

Comments