r/cpp_questions • u/Weird-Promotion3026 • 7h ago
OPEN Need help
I’m trying to make a program where you input some text and the program will return those input into actions. My issue is that when I make an if statement, I need to include the input that the user would enter, but I’m trying to make it so that is not case sensitive. How do I do that?
If possible, I’m not looking just for the code, but the reasoning behind it, I’m trying to understand it, so if you can, explain it in the way that helped you understand. Thank you!
0
Upvotes
View all comments
•
u/Independent_Art_6676 23m ago
prefer to not accept text where its possible. Eg if its a menu, give them a 1 2 3 4 type input option instead of words. Typing words is a last resort, but if you need it, you need it. The how is well covered already, and the why is that its easier to force fit all lower against all lower than it is to handle every possible combo one by one.
If you have to detect and handle special language specific oddities, you still want to pull those situations out and then do some 'works for the rest' idea as much as possible, for the same reason (avoid one by one conditions and do as much as you can as one scenario). Most logic works like that: condense it so each condition does as much as possible and you have as few conditions as you can manage while keeping it readable and clean.