Help Needed In C++ ....... Plz Don't Ignore

Status
Not open for further replies.

BBThumbHealer

BlackBerry Guru ! :)
hi frenz......


i m developing a program in turbo C++ v3......now i want the user to enter a password before accessing my program but i don't know how to do this ....


can u ppl help me plz......n temme how to make the code for this purpose !

Thnx....

BlackBerry7100g.
 

ilugd

Beware of the innocent
is that a console program?
If so, then just use something similar to the following
Code:
cout<<"Enter PIN";
cin>>intPin;
if intPin==MACROPIN then 
{
  //call a fn or whatever
}
else
{
cout<<"Access Denied";
return 9;
}
Hope this is what you were looking for.
 

anantkhaitan

Burning Bright
frnd u can use this

char a[]="password"; // U Can use ur own
char ch,b[20];
int i=0;
do
{
ch=getch();
b[i++]=ch;
cout<<"*"; // u can use ur own symbol
}while(ch!='\r') // \r has been used for Enter key
b[i-1]='\0';
if(strcmp(a,b)==0)
cout<<"correct"; //here u can use ur program
else
cout<<"access denied";
[/qoute]
 

n2casey

Super Hero - Super Powers
Use this code which have some more advantages:

  • Will allow use of Backspace
  • Will not scan Tab key & function keys such as F1, F2, Home, End ... etc.

Code:
#include<string.h>

void main()
{
char c='\0', d='\0', pt[50], ps[]="ur password";
int m=0,n=0;
clrscr();

 while(c!=13)
 {
	c=getch();

	if(c==13)
	{
		for(n; n>=0 ;n--)
		{ pt[m]='\0'; m--; }

		if(strcmp(pt,ps)==0)
		{
		cout<<endl<<"Password accepted."<<endl;
		/*Use ur prog here*/
		}

		else
		cout<<endl<<"Invalid Password!";
	}

	else if(c >31 && c <127)
	{
		for(n; n>0 ;n--)
		{ pt[m]='\0'; m--; }

		pt[m]=c; m++;
	}

	else if(c == 8)
	n++;

	else
	{
	if(c!=9)
	d=getch(); cout<<"\a";
	}
 }
 getch();
}
 
OP
BBThumbHealer

BBThumbHealer

BlackBerry Guru ! :)
hey n2casey....

ur code is workin for which i have repped u too.....

but this is a high level code for me......i m just a beginner to c++ n studying in class XI.....

can u plz make a code which is easily understandable for me....

Thnx...

BlackBerry7100g.
 

n2casey

Super Hero - Super Powers
BlackBerry7100g said:
hey n2casey....

ur code is workin for which i have repped u too.....

but this is a high level code for me......i m just a beginner to c++ n studying in class XI.....

can u plz make a code which is easily understandable for me....

Thnx...

BlackBerry7100g.

Thx for repu.
I will do ur job but don't u think that we can just manipulate this code so that u can understand it.
If u want somewhat different then tell me, what exactly u want.
 

n2casey

Super Hero - Super Powers
BlackBerry7100g said:
hey n2casey......

plz manipulate the code...

Thnx

BlackBerry7100g.

OK but which line from this code do u want to understand & which line do u want to manipulate?
 
OP
BBThumbHealer

BBThumbHealer

BlackBerry Guru ! :)
hey ilugd and anant.....

ur codes were gr8 too for which i have repped u both.....


and,aditya.shevade.........ur avatar is too cool man...

Thnx....

BlackBerry7100g.
 

aditya.shevade

Console Junkie
BlackBerry7100g said:
aditya.shevade.........ur avatar is too cool man...

Thnx....

BlackBerry7100g.

Thanks man. You have no idea what I and Vimal had been going through regarding my avatar.

Aditya
 
Status
Not open for further replies.
Top Bottom