Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need help to modify this code from a ?? syntax to standard micosoft visual C++ express syntax to do the same the same thing!

int countNumChars(int pass[]);
int countChars(char pass[]);
bool isValidPassword(char *password);

int main()
{    
    char pass[24];    // To store password

    cout << "password must have at least 6\n";    
    cout << "characters and one digit (1-9).\n";    
    cout << "Please enter a password: "; 
    cin >> pass;   

    while(!isValidPassword(pass))    
    {        
        cout << "Please enter password: ";        
        cin >> pass;    
    }    
    cout << "Thank you, that is a valid password.\n";    
    return 0;
}

bool hasNumChars(char pass[]) // definitions of digit of password characters.
{
    int len = strlen(pass);
    for (int count = 0; count < len; count++)
    {
        if (pass[count] >='1' && pass[count] <= '9')
        {
            return true;
        }
	else;
    }
    return false;
}

bool isValidPassword(char *password) // password validator
{    
    int len = strlen(password);

    if (len<6)
    {
        cout >> "Password must be at least 6 characters.\n";
        return false;
    }
    
    if(!hasNumChars(password))
    {
        cout >> "Password must have at least one digit(1-9).\n";
        return false;
   }
   return true;
}
Posted
Updated 17-Apr-10 18:19pm
v2

What is a question syntax?

-Saurabh
 
Share this answer
 
I have no idea what you're talking about. This looks like standard C++ to me. Unless you use non C++ includes, but you don't show that. C++ headers for things like string are not string.h, just string. iostream is the same.
 
Share this answer
 
Your question is not clear.
What exactly do your teacher mean with "?? syntax"?!?

Ask him to show you exactly what is the part of your code with such a problem.

Note: your code will not compile unless you prefix it with
C++
#include <iostream>
#include <string>
using namespace std;
 
Share this answer
 
i submitted this assignment but my teacher tells me its syntax is unacceptable because its a question syntax and needs to be modified. i am kinda of stuck !!!

[EDIT]
Don't "answer" putting "question": just edit your original question.
[/EDIT]
 
Share this answer
 
v2
His comments was simply you code uses ?? syntax in variable declarations which are not supported by the compiler!:confused:

[EDIT]
Don't "answer" putting "question": just edit your original question.
[/EDIT]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900