×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Password verifer

Password verifer

Password verifer

(OP)
I am writing a password verifier for a class project.  John send me his verson of class, which is a MSVC.  I am using ?Turbo C++ so I am having a hard time converting it.  Can someone help me on this problem

#include <iostream.h>
#include <iomanip.h>
#include <string.h>
#include <ctype.h>

class Password    // class declaration
{
  public:
Password();
Password(char);
check();
void setPassword(char);
  private:
HasUpperCase();   //check  for password
HasLowercase();
HasDigit();
char szPassword;
}

//implementation


Password::Password()

Password::Password(char szPassword)
{

  szPassword = szPasssPhase;
}

Password::check()
{
  while(bReturnValue != 0)
{
if((HasLowerCase()) &&
  (HasUpperCase())  &&
  (Hasdigit())      &&
  (szPassword.length() >=6))
cout<<"Your password is correct. Please process "<<endl;
}
  while (bReturnValue =0)
{
cout<< "Your password is incorrect.  exit and try again. "<<endl;
exit()
}
  return bReturnValue;

}
Password::HasLowerCase()
{
 int x;
 bRetVal =0;
 for(x=0;x<=(szPassword.lenght()-1); x++0
 {
if(islower((int)szPassword[x]))  //return a non-zero value if true
{
  bRetVal !=0;
  break;
}
 }

 return bRetVal;

 Password::HasUpperCase()
 {
bRetVal = 0;
int x;

for (x=0;; x<=(szPassword[x]))//returns a no-zero
  {
if(isupper((int)szPassword[x]))
{
(bRetval !=0)
break;
}

  {
  return bRetVal;
}

 Password::HasDigit()
 {
bRetVal =0;
int x;

for (x=0;x<=(szPasswordl.length()-1)
{
  if(isdigit((int)szPassword[x]))
  {
bRetVal !=0;
break;
  }
  return bRetVa;;
}
 int main()
 {
Password a, b, c , d;
cout<<"the password is: "
a.Password()
b.Password(string):
c.Check();
d.setPassword(string;
 }

RE: Password verifer

I've rewritten your code please check it if it solves your problem. But you had a lot of syntax errors.

#include <iostream >
#include <iomanip >
#include <string >
//#include <ctype>
#include <ctype.h>
#include <stdlib.h>
using namespace std;

class Password    // class declaration
{
public:
Password() { bRetVal = 0;}
Password(char* szPassPhase){
length = strlen(szPassPhase);
szPassword = new char[length+1];
strcpy(szPassword , szPassPhase );
}
int check(void);
void setPassword(char*);
private:
int HasUpperCase(void);   //check  for password
int HasLowercase(void);
int HasDigit(void);
char* szPassword;
int length;
int bRetVal;
};

//implementation

void Password::setPassword(char* string) {
strcpy(szPassword,string);
cout << szPassword << endl;
}

int Password :: check(){

while(bRetVal != 0){
if( (HasLowercase())  &&
(HasUpperCase())  &&
(HasDigit())      &&
(length >= 6))
cout<<"Your password is correct. Please process "<<endl;
}
if(!bRetVal) {
cout<< "Your password is incorrect.  exit and try again. "<<endl;
exit(0);
}
  return bRetVal;

}

int Password::HasLowercase(){
 bRetVal =0;
 for(int x=0;x < length; x++)
if(islower((int)szPassword[x]))  //return a non-zero value if true
{
bRetVal = 1;
break;
}
 return bRetVal;
}

int Password::HasUpperCase() {
bRetVal = 0;
for(int x=0; x<length;x++)//returns a no-zero
if(isupper((int)szPassword[x])){
bRetVal = 1;
break;
}
return bRetVal;
}

int Password::HasDigit() {
bRetVal =0;
for (int x=0;x<=length;x++)
if(isdigit((int)szPassword[x]))  {
bRetVal = 1;
break;
}
return bRetVal;
}


int main() {
char* string = "h123";
Password a = Password(string) ;
cout<<"the password is: " << endl;
a.check();
a.setPassword(string);
return 0;
}


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close