Code:
cin >> password;
getline(cin, password ,'\n');
This is wrong, and I'll explain why.
Input to your program is buffered. When you type in your password, it might look like this:
Code:
'l', 'a', 'l', 'a', '\n'....
The first line you have will read until it hits '\n' in this case. Reading strings with cin, however, means that the '\n' char is left in the input buffer. That means the input buffer will look like this:
getline() comes around and tries to read now. It reads into the same location you had cin read to. It reads this as an empty string and the output buffer is now empty because getline(), unlike cin, will eat up the '\n' char and discard it.
Your variable password is now an empty string, not "lala".
Solution: Get rid of the first line.