Jump to content
xisto Community
Sign in to follow this  
jibnet

How To Input A Password In C

Recommended Posts

We all know that C doesnt not provide us with any function to enter a password so that whatever we type doesnt get on the screen.
I had this problem and i have found a solution. i have made a funtion

#include <stdio.h>#include <conio.h>#include <stdlib.h>#include <string.h>getpassword(char[]);getpassword(char password[100]){char a;int ab=0;while(1){fflush(stdin);a=getch();if (a>47 && a<123){password[ab]=a;ab++;}else if(a==8){if(ab>0)ab--;}else if(a==13){password[ab]='\0';break;}}}

In turbo C++ 3.0
you can for e.g. call the function getpassword(char pass) which returns the string to pass.

Notice from BuffaloHELP:
Learn to use correct bbcode for CODEs posted.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.