Ok, I am a beginner at c++ and I cannot figure out the best way to compare a string to multiple strings....
Basically I want something to do this:
1. User enters name such as John Doe, but I want it to not matter if they type it in uppercase, lowercase, etc.
2. Name is checked against multiple strings such as...(john doe) (John Doe) (JOHN DOE)
3. if the name the user enters matches one of those the result is 0, or something similar.
What is the best way to do this? Is there a way that I could just type one string to compare it to the name the user enters instead of every possibility? So I need a way to compare it disregarding the uppercase, lowercase....I think.
Thanks for any help!
Also, I can never think of any programs to make for practice, is there a website with some ideas?
US Constitution Article II, Section 1, Paragraph 7
"The President shall, at stated Times, receive for his Services, a Compensation, which shall neither be encreased nor diminished during the Period for which he shall have been elected, and he shall not receive within that Period any other Emolument from the United States, or any of them."
and Article I, Section 9, Paragraph 8
"No Title of Nobility shall be granted by the United States: And no Person holding any Office of Profit or Trust under them, shall, without the Consent of the Congress, accept of any present, Emolument, Office, or Title, of any kind whatever, from any King, Prince, or foreign State."
e·mol·u·ment: a salary, fee, or profit from employment or office.
Just saying.
Question
PricklyPoo
Ok, I am a beginner at c++ and I cannot figure out the best way to compare a string to multiple strings....
Basically I want something to do this:
1. User enters name such as John Doe, but I want it to not matter if they type it in uppercase, lowercase, etc.
2. Name is checked against multiple strings such as...(john doe) (John Doe) (JOHN DOE)
3. if the name the user enters matches one of those the result is 0, or something similar.
What is the best way to do this? Is there a way that I could just type one string to compare it to the name the user enters instead of every possibility? So I need a way to compare it disregarding the uppercase, lowercase....I think.
Thanks for any help!
Also, I can never think of any programs to make for practice, is there a website with some ideas?
Link to comment
https://www.neowin.net/forum/topic/615897-how-to-compare-1-string-against-multiple-strings/Share on other sites
17 answers to this question
Recommended Posts