Hey so I've been fighting with this for a few days now. I'm trying to create a simple hangman game. The problem I'm having is understanding how to use the str::compare func.
1 2 3 4 5 6 7 8
Char answer[6];//I have tried to use just string answer; too
String a;
Cin >>answer;
Cin >> a;//for the first letter guess.
If(answer.compare(0,'a') == 0){
Cout << "you got it!!";
}elseif(answer.compare(0,'a') != 0){
Cout << "try again";
My question is, how do I use the compare function to compare only certain characters against a different string
I apologize for all the capitalizations, I've typed all this out from an android phone and it capatilizes some things. My code right now works, but it freezes after I give a letter. This is just a snippet of the full program. So it looks a little bare too. The rest is all simple cout intro statements with the rules and such.
I've been using the reference pages this whole time. I don't understand how to implement it into the coding though and I was wondering if I could just have an example that is more simplified, and similar to mine. Yet still makes me work for it a bit. I know that's asking a lot. At least with what I understand of programming. After almost an hour of playing around and trying I'm still lost. I have tried to use temp strings to store answer in a const char such ad:
1 2
Const string answer;
String realAnswer = answer;
And I've been trying to figure it out. If you stored the world 'Hello' then your first letter as an H in string a then it should be