Hello everyone, this is my first time creating a topic on this forum and I could really use the help. The problem with this code is the execution. Meaning, the result that I get is wrong(as far I know, the compiler gave me no errors or warnings). The "error" starts when the program asks the user to input the name of the race they wish to be. The problem is that it accepts anything(integers, literals, etc) when I specifically wrote to only accept any of the choices from my list and output an error message whenever they input the wrong thing. I will be taking any suggestions. In case you want to know, the program that I'm using for this is CodeBlocks. Also, please comment on my coding style. If you see any room for improvement in that department, please don't hesitate to comment.
in my situation specifically, if I don't use && then the retry loop doesn't work. It will just keeping giving me the error message that I placed in the do- while loop and not move on to the next line which is "Now it's time to pick your race".
when I wrote char gender = 'M' && 'F', what I thought I was doing was assigning two "values" to one variable so then when I create my if statement, gender could equal to only M or F(meaning if the user inputs any of those two character literals, it would be correct).
you said it makes no sense. If what you're saying is true, should I leave like char gender; or char gender = 'M' || 'F'.
edit-and for some reason you repeat the same statement(the char statement). Sorry I don't see the difference.
It only needs to be char gender;. '&&' is a boolean operator, so it doesn't make sense to assign it to a char :)
EDIT: you can only assign one value to a char at any given time. The '&&' operator gives you a truth-value, i.e. it returns true if both sides of it are true. For example true && false yields false, whereas true && true yields true. When I repeated the same statement before, it was just a typo, I corrected it later on.
Thank you for your input. I was finally able to solve it. Turns out you were right to suggest making each string equal to race separately. You still haven't commentated on my coding style though.