password code

justice igwe -3 Tallied Votes 372 Views Share

well am using the turbo c++ compiler , so you must convert it to cpp ( c++)
before u can use it ok. here we go.
steps:
(1)press the windows shortcut key and hold R or go click on RUN
(2) type in the following( C:/TC/BIN/TC.EXE) hit ENTER, wait for 5 seconds and then press f3 on the keboard.
(2) rename it to ur choice, but the extension should be in cpp eg..
(3) test.cpp or code.cpp. it should not be in tect.c or code.c
(4) there should be a #include<conio.h> header after #include<iostream.h>
WHAT THE CODE DOES:
this code will prompt for a password, but the character inputed will not be displayed,rather it replaces it with an asteriks so that the password becomes invisible to any user except YOU..
Headers like IOMANIP.H was included to manipulate the output .. i think with this code you can help yourselves out and write a protective program that cannot be accessed easily..
make sure u have a TURBO C++ compiler thanks enjoy it anything else just let me know......

#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
main()
{
char choice;
char n,i;
int y,z,sum;
char x;
clrscr();
loop:clrscr();
cout<<endl<<" Enter Your Password..... <  >   ";
gotoxy(21,2);
n=getch();
cout<<"*";
if(n!='y')
{
cout<<"\n Wrong Access Code \n\n Hit The ENTER key To continue ";
getch();
goto page:
}
else
{
cout<<"\n Access Granted.....\n\n Hit The ENTER key To Continue    ";
getch();
clrscr();
cout<<"\n  C++ calculator Programmed By Igwe Justice Chikaodi ";
cout<<"\n Main Menu  ";
gotoxy(20,4);cout<<"\n Press (a) for Addition \n Press (b) for Multiplication \n  Enter Choice  < >  ";
gotoxy(17,7);
cin>>x;
switch(x)
{
case 'a':clrscr();
cout<<"\n Addition Department :  :  ";
cout<<"\n Enter Two Numbers     ";
cin>>y>>z;
sum=( y+z);
cout<<"\n The Sum of "<<y<<" and "<<z<<" is "<<setw(6)<<sum<<endl;
cout<<"\n Thank You ";
getch();
break;
case 'm':clrscr();
cout<<"\n Multiplication Department :  :  ";
cout<<"\n Enter Two Numbers     ";
cin>>y>>z;
sum=( y*z);
cout<<"\n The Procuct of "<<y<<" and "<<z<<" is "<<setw(6)<<sum<<endl;
cout<<"\n Thank You ";
getch();
break;
default:
cout<<"\n Hope U enjoyed The Calculator    ";
}
page:clrscr();
cout<<"\n Do You want To Continue again (y/n) :  ";
cin>>choice;
if((choice=='y')||(choice=='Y'))
{
goto loop;
}
else if((choice=='n')||(choice=='N'))
{
cout<<"\n ThanK You For Using Igwe's Program ";
}
}
getch();
}
rahul8590 71 Posting Whiz

1. People need not to have a single character as a password , ur code works only for a single character.

2. Goto is a very very bad & unstructured style of programming , double whammies like that are rare.

3.For , god sake stop using the old freaking turbo C++ compiler , there are much better compilers like gcc, boroland etc.

commented: 3 EXCELLENT points! +18
commented: Yes-Please recycle anything else except for Borland code +1
CppBuilder2006 -5 Junior Poster

Even the latest version of Borland C++ supports an old code written for turbo C 1992!

the code had a simple misprint, I corrected:

#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
main()
{
	char choice;
	char n, i;
	int y, z, sum;
	char x;
	clrscr();
loop:
	clrscr();
	cout << endl << " Enter Your Password..... <  >   ";
	gotoxy(21, 2);
	n = getch();
	cout << "*";
	if (n != 'y')
	{
		cout << "\n Wrong Access Code \n\n Hit The ENTER key To continue ";
		getch();
		goto page;
	}
	else
	{
		cout << "\n Access Granted.....\n\n Hit The ENTER key To Continue    ";
		getch();
		clrscr();
		cout << "\n  C++ calculator Programmed By Igwe Justice Chikaodi ";
		cout << "\n Main Menu  ";
		gotoxy(20, 4);
		cout << "\n Press (a) for Addition \n Press (b) for Multiplication \n  Enter Choice  < >  ";
		gotoxy(17, 7);
		cin >> x;
		switch (x)
		{
			case 'a':
				clrscr();
				cout << "\n Addition Department :  :  ";
				cout << "\n Enter Two Numbers     ";
				cin >> y >> z;
				sum = ( y + z);
				cout << "\n The Sum of " << y << " and " << z << " is " << setw(6) << sum << endl;
				cout << "\n Thank You ";
				getch();
				break;
			case 'm':
				clrscr();
				cout << "\n Multiplication Department :  :  ";
				cout << "\n Enter Two Numbers     ";
				cin >> y >> z;
				sum = ( y * z);
				cout << "\n The Procuct of " << y << " and " << z << " is " << setw(6) << sum << endl;
				cout << "\n Thank You ";
				getch();
				break;
			default:
				cout << "\n Hope U enjoyed The Calculator    ";
		}
page:
		clrscr();
		cout << "\n Do You want To Continue again (y/n) :  ";
		cin >> choice;
		if ((choice == 'y') || (choice == 'Y'))
		{
			goto loop;
		}
		else
			if ((choice == 'n') || (choice == 'N'))
			{
				cout << "\n ThanK You For Using Igwe's Program ";
			}
	}
	getch();
}

for a longer password you should add a loop.

iamthwee commented: nope -2
justiceigwe 0 Newbie Poster

thanks alot

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.