so im working on a function that gets two strings of chars.
The function returns the same number of characters that are in the same position in both strings. The function does not distinguish between lower and upper case letters.
my program is working. Only problem is that i cant find way to make the function case insensitive.
for example:
mama
MAjk
shout return 2.
so here's the code.
i want to figure out a way to do it without a built in system function.
thanks in advance!
you can't really. The usual way is to compare toupper or tolower of each character
eg
tolower(str1[i]) == tolower(str2[i])
be warned sometimes this gives odd results for Unicode. I think the issues are when the same letter visually is differently coded, but I am not an expert on the issues.
Did you read what he said? Yes, of course, you can achieve almost anything in programming.
You just need to loop through each character and call tolower() on each character before you compare with ==.
jonnin already showed you the code.
Also, don't worry about unicode, it's certainly outside the scope of your assignment.
Possibly bad wording on my part.
C++ does not have a lot of the 'string processing language' stuff that many scripting languages have, such as a caseless compare done for you. You have to build it from what you do have.