Home » C SOURCE CODES

C Program To Accept Password

Submitted by Srikanth on Tuesday, 11 December 20077 Comments

This is a simple login program in C. While accepting password it masks each character using ‘*’ symbol and display the password in the next line after the user hits Enter key. It also accepts backspaces and acts accordingly.

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

char pw[25],ch;
int i;
void main()
{
clrscr();
puts(“Enter password”);
while(1)
{
if(i<0)
i=0;
ch=getch();
if(ch==13)
break; /*13 is ASCII value of ENTER*/
if(ch==8) /*ASCII value of BACKSPACE*/
{
putch(‘\b’);
putch(NULL);
putch(‘\b’);
–i;
continue;
}
pw[i++]=ch;
ch=’*';
putch(ch);
}
pw[i]=’\0′;
printf(“\n\n%s”,pw);
getch();
}

Popularity: 1% [?]

Visitors who read this post, also read:

  1. How to Hack Windows Administrator Password

  2. How to Make Invisible Password Protected Folder


  By using/following this site you agree to our Legal Disclaimer

Subscribe to GoHacking.Com


Enjoyed this article?
Subscribe to GoHacking.Com and get daily updates in your email for free

7 Comments »

  • Doodle77 said:

    Go home.

  • Anonymous said:

    Wats great in this?

  • Everyone said:

    Good

  • Virendra said:

    hi Shrikant,
    can you please tell me from where can i get c compiler

  • Srikanth (author) said:

    @ Virendra

    Goto Borland site. Or search on google for Turbo C/C++ compiler

  • crusader said:

    I was wondering if dev-c++ is a good compiler? and if it compiles in c also? Thanks

  • Akash said:

    Hi Srikanth Bro …
    I use Turbo c++ 3.1
    Which is the best for writing, Editing and compiling C Program ???

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.