I am a new user of c++ and not really clear on pointers and the like , I have tried to search the web for some reasonable explanation but they just don't make much sense to me still. I would like to know what I need to do to pass this string to my boolcheckpassc(char *) function and if you just explain it in plain words that would be great cause I am lost. The bool code is from my book page 542 of starting out with c++ control structures. The other code is from some other program I had with a dynamic array that I got an failure on anyway. I don't want you to write the code I just want someone to explain what I need to do to get it to work. like do I need to put in char instead of string? I am so confused. My instructor is of no help and he works for the air force.

#include<iostream>
#include<iomanip>
#include<string>

using namespace std;




/***************************************************************************/
/***************prototypes**************************************************/
void pause ();
int menu ();
string namePassword (string &newuser, string &pass);
void verifylogin();
bool checkpassc(char *);
int checkupperc(char *);
int checklowerc(char *);
int checknum(char *);
int checkspace(char *);





/****************************************************************************/
/******************main function*********************************************/

int main()
{
    int cont = 2;
   string *username;//ptr to dynamic array to hold names of products
   string *passwords; //ptr to dynamic array to hold prices of products
   int size =0;//hold the size of the dynamic array
   string s1;
   string s2;
    do        
   {// start do
      int choice=menu (); // call to the menu function
      switch (choice)
      { // Open switch statement

/******************************************************************************/
/**********switch case one register username password**************************/

         case 1: 

              //Get the information from the user for the product
              namePassword(s1,s2);
              cout<<"\n\n Enter a username:\n  ";
              cin>>s1;
              cout<< "\tEnter a password with the following criteria:\n";
              cout << "8 to 15 characters\n"; 
              cout<< "2 uppercase\n2 lowercase\n2 numbers\n2 special characters:\n";
              cin >> s2; 

   int length;
    length = strlen(s2);

    if(length >= 8 && length <= 15)
    {
        while (!checkpassc(s2))    
       {        
          cout << "Invalid Password. try again\n";        
          cin >> s2;    
       }    
       cout << "Your password: " << s2 << ", is valid\n";    
    }
    else
        cout << "The password entered must be between 8-15 characters long\n";            

    system("pause");    


            pause();
            break;

/*****************************************************************************/
/******************switch case 2  login **************************************/ 

      case 2://get  the login information from the user
             case 2://get  the login information from the user
 char lookUp[user];
 char *strptr=null;
 int index
 cout<<"enter username\n:";
 cin.getline(lookUp,user);

 for (index=0; index<user; index++)
 { 
     strPtr=strstr(user[index],lookup);
 if (strPtr !=Null
 cout<<"incorrect username\n";
 }
 if(strPtr!


            pause();
            break;

/******************************************************************************/
/******************************************************************************/

         case 3:cont=0;
                 break;
          } // Close switch statement

   }while (cont ==2);
   return 0;
}// STOP MAIN

/******************************************************************************/
/*******************void Pause function****************************************/

void pause ()
{//clears the last 80 on buffer
   cout << "Press enter to continue " << endl;
   cin.ignore (80, '\n');
}

/*****************************************************************************/
/**********int menu funtion********************************************/

int menu () 
{ // start int menu prototype

   int c = -1;
   while (c<1 || c>4)
   {  // start menu
      system ("cls");
      cout << " 1. Register\n\n\n"
           << " 2. Login\n\n\n"
           << " 3. Exit\n\n\n";


      cin >> c;
      cin.ignore (80, '\n');
   }//end of while loop
   return c;
}// close int menu prototype

/******************************************************************************/
/******************user name function**********************************************/
string namePassword (string &newuser, string &pass);
{

} 
/****************************************************************************/
/*******************password registration*************************************/
bool checkpassc(s2 *str)
{    

    int length = strlen(str); //function to deterine the length of the cstring
    return checkupperc(str) && checklowerc(str) && checknum(str) && checkspace (str);
}
//test for upper case 
int checkupperc(s2 *str)
{
    int user = 0;
    int length = strlen(str);

    for (int count = 0; count < length; count++)
    {
        if (!isupper(str[count]))
        user++;
    }
        return user;    
}
//test for lower case
int checklowerc(s2 *str)
{
    int user = 0;
    int length = strlen(str);

    for (int count = 0; count < length; count++)
    {
    if (!islower(str[count]))
    user++;
    }
    return user;
}
//test if it is a number or alphabet
int checknum(s2 *str)
{
    int user = 0;
    int length = strlen(str);

    for (int count = 0; count < length; count++)
    {
        if (!isdigit(str[count]))
        user++;
    }
        return user;
}
//test if the argument is a whitespace character
int checkspace (s2 *str)
{
    int user=0;
    int length= strlen(str);

    for(int count=0; count<length; count++)
    {
            if(!isspace(str[count]))
            user++;
            }
            return user;
            }

you can ignore the login function as  that is just  an idea I am currently working on for the login verification

pass this string to my boolcheckpassc(char *)

You don't have a function named boolcheckpassc that accepts a char-pointer.

I would like to know what I need to do to pass this string to my boolcheckpassc(char *) function and if you just explain it in plain words that would be great cause I am lost.

Your prototype(bool checkpassc(char *);) has to agree with your declaration of the actual function(bool checkpassc(s2 *str)). Changing both to a string will get them to agree.

bool checkpassc(string);

bool checkpassc(string str)
{
    int length = strlen(str.c_str()); //function to deterine the length of the cstring
    return checkupperc(str) && checklowerc(str) && checknum(str) && checkspace (str);
}

yes that's making sense now , thats what I was wondering . My book was explaining like everything had to be char. So I can just make it all string that's great . let me go modify and I will repost.

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.