So, my assignment is to write a program that puts a password input from the user through various tests and output its level of security. I've not had much training in this as my teacher doesn't really help much, and I'm supposed to do this over spring break.

#include <iostream>
#include <string>
bool is_even(string); //prototype

using namespace std;


int main()
{
	string password, verbose;
	int sec1, sec2;
	
	cout << "Passowrd Strength Checker!"<<endl;
	cout << endl;
	cout << "Enter the password to check: ";
	cin >>password;
	cout << "Enter the two security codes: ";
	cin >>sec1>>sec2;
	cout << "Verbose? (y/n) ";
	cin >>verbose;
	cout << "--------------------------------------"<<endl;
    return 0;
}

bool is_even(string password)
{
	if((password.size() >=8) && (password.size()<=14))
		return true;
	else
		return false;
}

I'm using XCode on my Mac, and when I try to compile this it says that string wasn't declare in the scope and that bool is_even(string password) was redeclared as a different kind of symbol. I can't find an example of doing what exactly what I want to do. Basically, this part of the code needs to take the password from the user, and see that it's between 8 and 14 characters, and also even. Any help is very appreciated.

You need to move the using namespace std; line to be above the function prototype.

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.