Hi.First time poster, please be gentle with me lol.
I'm trying to work out why this code fails at
Code:
getline( cin, username, "\n");
if I use double quotes instead of the single quotes which was used in the example from the book.
Here is the full code that works with single quotes at each "getline line". I guess what I'm asking is if there is a difference or am I using the wrong header? I was sure that you could use either but I cant find where I read that now.
Code:
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string username;
string password;
cout << "Enter your username: " << "\n";
getline( cin, username, '\n');
cout << "Enter your password: " << "\n";
getline ( cin, password, '\n');
if (username == "root" && password == "xyzzy" )
{
cout << "Access Allowed" << "\n";
}
else
{
cout << "Bad username or password. Access Denide!" << "\n";
return 0;
}
}
Thanks for any assistance.
Oh I'm using Code::Blocks 13.12! if that makes any difference.