Multiple Strings

Hi I just recently began learning how to program in C++ and I ran into a bit of a problem.
What I am trying to do is make the code below give me the option to put in two or more password options and for each different password I get a different response. Lets say the password is "cheesecake" like the bottom one and it says "access granted" what i want to do is give it a second option (possibly more than two) and response. For example if i just type "cheese" it would give me another text saying something like "close but no cigar" How would I go about doing something like that? Any and help is gratefully recieved ^_^


--------------------------------------------------------------------------------
#include <iostream>
#include <stdio.h>
#include <string.h>


using namespace std;

int main(){

char myArray[50];

cout << "Whats the password? ";

cin.getline( myArray, 50, '\n');

if( !strcmp( myArray, "cheesecake")){

strcat( myArray, " is correct! Access granted!\n");

} else {

strcpy( myArray, "Invalid password!\n");

}

cout << myArray;

system("pause");

}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
#include <iomanip>
#include <limits>

using namespace std;

int main() {

	cout << "Please enter password: ";
	string password = "";
	getline(cin, password);

	if (password == "cheesecake")
		cout << "Cheesecake!" << endl;
	else if (password == "pluto")
		cout << "Pluto!" << endl;
	else
		cout << "Sorry, " << password << " is invalid" << endl;

	return 0;
}
wow thanks for the speedy reply but I got an error message. I should probably let you know that I am using "Microsoft Visual C++ 2010 Express" to run stuff.
Anyway this is what I got back:

1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\ostream(447): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(long double)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\ostream(467): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(const void *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\ostream(487): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::basic_streambuf<_Elem,_Traits> *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> while trying to match the argument list '(std::basic_ostream<_Elem,_Traits>, std::string)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Add #include <string> to the group of #includes. That should fix the problem.
thanks! :D
Topic archived. No new replies allowed.