I have only just started programming in C++, so please bare with me, but after reading quite a lot over the weekend, I managed to make a simple yet "imperfect" password protection on entry to a program, similar to a login. Here is my code:
#include <iostream>

//An attempt at password protection
//By J_K9   -- 10/07/2005

int main()
	const int passwd = 13579;
	int input_passwd;
	std::cout << "Please enter your password: ";
	std::cin >> input_passwd;
	if (input_passwd == passwd)
		std::cout << "\nEnter!\n";
		std::cout << "\nSorry! Wrong password!\n";
	return 0;
I have compiled this and I know it works. Then I decided that I wanted an alpha-numeric password, but I had an odd complaint from g++ when I tried replacing the "int" values with "char", and changing the passwd to "lycrolite" (including speech marks). My code can be found here. The error I received was:
jk9@ubuntu:~/CPP/000my_stuff/pass_prot2$ g++ passprot2.cpp
passprot2.cpp: In function `int main()':
passprot2.cpp:8: error: invalid conversion from `const char*' to `char'
I didn't understand what the problem was, as I had checked and rechecked the code and it seemed flawless, but then I asked a member of another forum and he told me that I needed to use either string classes or character arrays, and he rewrote it as it should be (his code can be found here).

I will read up on string classes and character arrays, but can I just quickly ask what that did, and why his works whereas mine doesn't? In the book I'm currently learning C++ from (SANS Teach Yourself C++ in 24 Hours, because "Accelerated C++" hasn't arrived yet in the post) it didn't mention the "string" value, which I actually used to use a lot with BASIC variables. I thought that from the information provided in the book, the only values allowed for strings were "char" and "float", but obviously "string" also exists....Yet, why do you need to "#include string"? Does this mean that "string" is not a variable type? Please teach me what's going on ! Thank you!


P.S Is it possible to decompile an a.out file so that you can see the original source code? I don't think so but I just want to check, because if not that would really defeat the purpose of my code!