I'm experiencing an issue with my code below. What happens, is that after the user enter an account name, all the cout are being ran, and then the program exit (see screenshot below). http://imgur.com/CYdJGRS
//bankaccount system with reg and login system (one time use)
#include <iostream>
usingnamespace std;
int main()
{
//register
cout << "Welcome Jocke's Bank! Please register an one-time use account below." << endl;
char regAccName, acc;
int regPwd;
int pwd = 65782;
cout << "Please register an account name: ";
cin >> regAccName;
cout << "Here is a one-time use password to your account: " << pwd << endl;
acc = regAccName;
//login
cout << endl;
cout << "Please login with your one-time-use account below:" << endl;
cout << "Account Name: ";
cin >> regAccName;
cout << "Password: ";
cin >> regPwd;
if (regAccName == acc && regPwd == pwd)
{
cout << "Successfully logged in!" << endl;
}
elseif (regAccName != acc)
{
cout << "Incorrect account name." << endl;
}
elseif (regPwd != pwd)
{
cout << "Incorrect password." << endl;
}
else
{
cout << "Something gone wrong. Please restart the program." << endl;
}
return 0;
}
I tried to only run the "register" part in the code (by making the "login" code into comments), and the same problem occured. The thing that's not working as it should, is that the code doesn't allow me to enter the password etc, it's like it doesn't read the cin. I also tried renaming the variables of the cin (so it doesn't "c-in" the same variable name twice, but no positive results were given.
I simply can't find an issue in the code either.
Any help is appreciated!