43 C Program to Illustrate how User Authentication is Done
Posted by Superadmin on December 23 2015 03:27:33
This C Program illustrate how user authentication is done. The program accepts the username and password. It checks whether the password is correct with respect to the username.
Here is source code of the C program to illustrate user authentication. The C program is successfully compiled and run on a Linux system. The program output is also shown below.
/*
* C program is to illustrate how user authentication is done.
* Program asks for the user name and password and displays
* the password as '*' character
*/
#include <stdio.h>
void main()
{
char password[10], username[10], ch;
int i;
printf("Enter User name: ");
gets(username);
printf("Enter the password < any 8 characters>: ");
for (i = 0; i < 8; i++)
{
ch = getchar();
password[i] = ch;
ch = '*' ;
printf("%c", ch);
}
password[i] = '\0';
/* Original password can be printed, if needed */
printf("\n Your password is :");
for (i = 0; i < 8; i++)
{
printf("%c", password[i]);
}
}
$ cc pgm43.c
$ a.out
Enter User name: rajaraman
Enter the password : shashi12
********
Your password is :shashi12