The program contains a class password which contains a constructor to initialize the actual password.......
there are also to other function...
the first one is to input the password
and the second one is to compare the input password to the actual one.....
If the two passwords are same then the program outputs "Correct Password"
else it says "incorrect Password"
The Problem: Whenever I run the program,TC++ crashes though there are no errors and warnings.....
the window just closes......
I think there must be a logical error....
But i cannot find where.....
Please guys helm me find out.....
The code is:
#include <iostream.h>
#include <conio.h>
#include <string.h>
class password
{
char pass[20]; //Stores Actual Password
char inpass[20]; //Stores Input Password
public:
password(char []); //Initializes Actual Password
void input(); //Inputs the Password
int comp(); //Compares the Password
};
void password::password(char p[])
{
int len=strlen(p);
for(int i=0;i<len;i++)
{
pass[i]=p[i];
}
}
void password::input()
{
char temp;
cout<<"Enter Password(!to end): ";
for(int i=0;temp!='!';i++)
{
temp=getch(); //After first Edit
inpass[i]=temp; /
cout<<"*";
}
}
int password::comp()
{
int temp;
temp=strcmp(pass,inpass);
return temp;
}
void main()
{
password pass("password");
clrscr();
pass.input();
if(pass.comp())
cout<<"\nCorrect Password";
else
cout<"\nIncorrect Password";
getch();
}
This post has been edited by sumit.xxx365: 01 October 2010 - 02:05 AM

New Topic/Question
Reply



MultiQuote







|