New Member FAQ | Forums | Earn Revenue


Resources Entrance Ask Experts Exam Papers Jobs English Projects Universities Colleges Courses Schools Training My India



My Profile
Active Members
TodayLast 7 Days more...



Awards & Gifts
Online Exams

Fresher Jobs


Our fresher job section is exclusively for fresh graduates! Find jobs for freshers in major Indian cities including Bangalore, Chennai, Hyderabad, Pune or Kochi

Resources


Find educational articles, blogs, discussion threads and other resources.

Colleges


Find details about any college in India or search for courses.

website counter



Password program in C (masking characters)


Posted Date:     Total Responses: 0    Posted By: Pratik Pansare   Member Level: Gold   Points/Cash: 6   


/*This program takes a username and password with programmer defined masking characters.

char* getData(char*,unsigned int,char);

Pass the character array where you want to store the password as first parameter.

The second parameter being the size of the array.

And the third parameter is the masking character for your password put 0 in case if you don't want your password to be masked.

This method also provides auto stop when your array reaches it maximum length it waits and does not take any more input from the user, it wait for the enter key or the backspace key to be pressed by the user just like a text box in html.


*/
#include
#include
#include

char* getData(char*,unsigned int,char);

void main()
{
char uname[20], pass[20];
clrscr();
printf("Enter username: ");
getData(uname,sizeof(uname),0);
printf("Enter password: ");
getData(pass,sizeof(pass),'#');
printf("\n\nUsername: %s & Password: %s",uname,pass);
getch();
}

char* getData(char *string,unsigned int size,char mask)
{
char ch=0;
int pos=0;

while(1)
{
ch = getch();
if(ch==13) //For enter key
{
*(string + pos) = '\0';
break;
}
else if(pos==size-1 || ch==27)
{
continue;
}
else if(ch==8 && pos>0)
{
printf("\b");
if(mask==0)
{
printf("%c",*(string + pos));
printf("\b ");
}
else
{
printf("%c",mask);
printf("\b ");
}
printf("\b");
pos--;
}
else if(ch!=8)
{
*(string + pos) = ch;
if(mask==0)
printf("%c",ch);
else
printf("%c",mask);
pos++;
}
}
return string;
}


Project Feedbacks


No feedbacks found. Be the first to respond and make money from revenue sharing program.

Post Feedback
You must Sign In to post a feedback.
Next Project: CODING FOR STUDENT RECORD MANAGEMENT SYSTEM
Previous Project: INTRANET SEARCH ENGINE

Return to Project Index

Post New Project


Related Projects



Advertise Here





Contact Us   Advertise   Editors    Privacy Policy    Terms Of Use   

ISC Technologies.
2006 - 2009 All Rights Reserved.