Thanks.
Using geany editor on ubuntu 12.04. no warning though.
I did another one a minute ago for setting a variable and then using it:
Code:
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string setUsername;
string setPassword;
string username;
string password;
cout << "Please set a username: " << "\n";
getline (cin, setUsername, '\n');
cout << "Please set a password: " << "\n";
getline (cin, setPassword, '\n');
cout << "Please login with your username and password" << "\n" //read a second ago in another post that subsequent cout commands can be combined rather than one per line
<< "Please enter your username: " << "\n";
getline (cin, username, '\n');
cout << "Please enter your password: " << "\n";
getline (cin, password, '\n');
if ((username == setUsername) && (password == setPassword))
{
cout << "Thank you. Access permitted" << "\n";
}
else
{
cout << "Sorry, wrong username or password. Try again." << "\n";
}
return 0;
}
That's the last example, I promise!
Does this line need to be:
Code:
if ((username == setUsername) && (password == setPassword))
or
Code:
if (username == setUsername && password == setPassword)
Or does it not matter?
Sam.