OK, maybe I need to explain it better. I know you can't ignore repeated characters as for the condition of an anagram to be fulfilled, every character has to appear in array1 as much as it appears in array2. However this is what I meant. Say arary1 is : desperation and array2 = aropeendsit.
Here, what my loop did was, it takes d, counts its number of occurrences in array2, then does the same for e and so on. Now because there is more than one e, it will count the occurrences of es two times instead of counting their occurrence only once. But I think I figured out how to solve it, with a break.
Code:
bool IsAnagram(char *array1, char *array2) {
bool anagram = true;
int counter = 0;
for (int i = 0; array1[i]; ++i) {
counter1 = 0;
for (int k = 0; array2[k]; ++k)
if(array1[i] == array2[k]) {
counter1++;
if(counter1 >1) break;
counter++;
}
counter++;
//if counter is not equal to length of array1, return anagram = false;
}
}