Hello.
I don't think the problem is that the program doesn't like the if(hash == 'a') part.If you first types 1, then afterwards types 97,I think the program will like it.
I think the reason is that cin refuse to give the value of char to a int number,but the '=' can.So when you input a char,cin give 0 to the int number and when we input 97,the value of "hash=='a'" is not zero,is true.We can use hash = 'a' to give hash a valid value,it's 97,but we can't use cin>>hash to do this.
Try this:
type 1.2,then see the value of hash is what.It's 1.
The reason is that to float number,'=' and cin both convert it to a int number and give the result to hash.
Clear?We can't use cin>>hash to give a char's value to hash,we can only use it to give a int number's value to hash.
niuwei
|