For some reason, it works when I just do the entering the name part it works fine, but with the rest of my program I'm having a problem. I'm trying to have the program make it where they enter a password to get in the program (Which I got to work, even though I know it's not extremely secure.) and after that I want them to enter their full name for later use in the program, but for some reason it just skips the part where they're supposed to input their name. Could someone tell me what I did wrong/what I need? (Also, if this is in the wrong place, I apologize greatly. I've never posted on here before.)
#include<iostream>
#include<windows.h>
#include <string>
using namespace std;
string password;
char name [200];
int main()
{
cout << "Enter your password.\n";
cin >> password;
if(password == "testpassword")
{
cout<<"Please enter your first and last name: \n";
cin.get(name, 200);
cin.ignore(250, '\n');
cout << "Welcome back, " << name;
system("pause");
}
else
{
system("CLS");
system("title Incorrect Password");
cout << "Incorrect password.\n";
cout << "This program will now close.\n";
Sleep(5000);
}
return 0;
}