I've been trying to set up a kind of password confirmation code for fun. Containing strings and conditions. And I can only imagine this has 1001 errors that you may see that I cannot. Just give me any suggestions:
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
|
#include <iostream>
#include <conio.h>
#include <string>
using namespace std;
int main()
{
char password;
char mypassword;
char a;
char b;
char c;
string correct = password;
string incorrect = "\n\nInvalid password.";
cout << "Please enter your password:\n" << endl;
cin >> mypassword;
a = correct;
b = mypassword;
c = (a==b) ? correct : incorrect;
cout << c;
return 0;
}
|
What do you think? And does this seem like an efficient way to do password confirmations?
Also, the following mistakes keeps coming up:
error: invalid conversion from 'char' to 'const char*'|
error: initializing argument 1 of 'std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, const _Alloc&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]'|
error: cannot convert 'std::string' to 'char' in assignment|
error: cannot convert 'std::string' to 'char' in assignment|
Any advice/suggestions?