EMERGENCY!! I NEED TO SUBMIT THIS PROJECT BEFORE TUESDAY

"How to create login id and password"
somebody help me to fix it
because i have to submit this assignment next weeks
i dont know how to using passing by value or reference corectly/

For the Ouput its say this :
1>ClCompile:
1> GILA DAH!!.cpp
1>d:\computer programmin ditg 1113\jiwa ku sakit\jiwa ku sakit\GILA DAH!!.cpp(21): error C2664: 'strlen' : cannot convert parameter 1 from 'char' to 'const char *'
1> Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
1>
1>Build FAILED.


#include <iostream>
#include <string>
using namespace std; //introduces namespace std
void length(char[]);

int main()
{
char pass;
string username = " ";
string password = " ";
bool loginSuccess = false;

cout << "\tWelcome!! Please login.\n\n " ;

do
{
cout << " username : ";
cin >> username;
cout << " password : ";
cin >> password;
length = strlen(pass);
cout << " pass : " <<length<<endl;

if (username == "apai" && password == "1993")
{
cout << " \nSuccessful Login\n\n" ;
loginSuccess = true;
}
else
{
cout << " Incorrect username and password again \n " ;
cout << " Please try to login again. ";
}


}while (!loginSuccess);


void length(char password);

if(pass <= 4)
{


bool pass = true;

}
else
{

bool pass = false;

}

cout << " Please try again "<<endl;

return 0;

}
Last edited on
Does it have to be that code? I mean you don't even use the length function and C++ has other ways of doing that. Here is the C++11 (mainly for auto) code I did, but it isn't the exact same as your code above:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <iostream>
#include <string>
//using namespace std; //introduces namespace std
// personally I don't like using anymore
bool length(std::string password);

int main()
{
	std::string username; // string data types are always initialized to empty
	std::string password;
	bool loginSuccess = false;

	std::cout << "\tWelcome!! Please login.\n\n " ;

	do
	{ 
		std::cout << " username : ";
		std::cin >> username;
		std::cout << " password : ";
		std::cin >> password;
		auto len = password.size();  // (auto)matically let compiler deduce that len is of type string::size_type
		std::cout << " pass : " << len << std::endl;

		/*
		 * if username is apai AND if password is 1993 AND 
		 * if length of password is 4 characters or less
		 * output success and exit program 
		 * else output error message and try again
		 */
		if (username == "apai" && password == "1993" && length(password)) // added length() so it was at least used
		{
			std::cout << " \nSuccessful Login\n\n" ;
			loginSuccess = true;
		}
		else
		{
			std::cout << " Incorrect username and password again \n " ;
			std::cout << " Please try to login again. \n";
		}


	}while (!loginSuccess);
	
	return 0;
}

bool length(std::string password) // not sure why we need this
{
	if(password.size() <= 4)
		return true;
	else
		return false;
}

Last edited on
Topic archived. No new replies allowed.