C Program to mask password text with asterisk(*)

C Program to mask password text with asterisk(*). This program is to illustrate how user authentication is made before allowing the user to access the secured resources. It asks for the user name and then the password. The password that you enter will not be displayed, instead that character is replaced by ‘*’. Read more about C Programming Language .

/***********************************************************
* You can use all the programs on  www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
* 
*                        Happy Coding
***********************************************************/

#include <stdio.h>
#include <conio.h>

void main()
{
 char pasword[10],usrname[10], ch;
 int i;
 clrscr();

 printf("Enter User name: ");
 gets(usrname);
 printf("Enter the password <any 8 characters>: ");

 for(i=0;i<8;i++)
 {
  ch = getch();
  pasword[i] = ch;
  ch = '*' ;
  printf("%c",ch);
 }

 pasword[i] = '';

 /*If you want to know what you have entered as password, you can print it*/
 printf("nYour password is :");

 for(i=0;i<8;i++)
 {
  printf("%c",pasword[i]);
 }
}
Read more Similar C Programs
Searching in C
C Strings

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com