ok well this is kinda dumb and i run into it alot. i always find a way around it but i dont know how to solve it. here is the code, it is a part of some stupid thing i am making please help me out. the problem is that when even you enter "command" it always outputs the response for help. please help. lol. the code Code: cin>>commands; //will output the help info if (commands == "help" || 'h'){ cout<<"help files"<<endl; cout<<"\n\n\n ok?"<<endl; cin>>a; gameplay(); } if (commands == "dive" || 'd'){ cout<<"how far?"<<endl; cin>>varDepth; comments = "you have dove down "; varDepth; currentDepth = currentDepth + varDepth; gameplay(); }
Hi, The reason is simple.. ur trying to compare ( (commaand == "help") || 'h') which is always true.try to compare it with (command== "help") || (command == "h")
ah, thank you jayaraj_ev. i know it would be easy i just never read how to compair two strings, thanks