"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.
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:
#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)
returntrue;
elsereturnfalse;
}