I'm preparing myself for my Intro to C++ class that I will be taking in the fall, so right now I'm just self taught using a book I bought recently.
I'm trying to compare two strings ignoring case and using functions and a loop. My book wants me to use a loop to call the toupper function for every character.
The program has no syntactical errors, but I just took a shot in the dark at the comparison. My problem is that it returns false every time. Thanks in advance!
The entire program code so far (updated, and still returning false):
This takes a copy of the string, alters the copy, then returns another copy of that copy. So, your name1 and name2 are never actually getting changed. With your usage, you'd want to change the method to:
void upperCaseIt(string &s)
This way it takes a reference of the string, then makes the changes.
Or, just use the return value of your current implementation of upperCaseIt (I use the return value as arguments in the changes I made).
I made some changes which should work (didn't actually test it). I made your code conform a little bit more to best practices.