method to decide if two strings are anagrams I'm studying with the Cracking the Code Interview book. I'm just looking for some feedback on this method:

C++

bool areAnagrams(const char*s1, const char*s2){
    unordered_map &lt;char,int&gt; m1,m2;

    for(size_t i = 0; i &lt; strlen(s1); i++){
        m1[s1[i]] += 1;
    }
    for(size_t j = 0; j &lt; strlen(s2); j++){
        m2[s2[j]] += 1;
    }
    for(auto i = m1.begin(); i != m1.end(); i++){
        if(m2[(*i).first] != (*i).second)
            return false;
    }
    return true;
}
Bug
Your algorithm is not quite correct.  For example:
areAnagrams(&quot;abc&quot;,  &quot;abc&quot;)  -&gt; true  (correct)
areAnagrams(&quot;abc&quot;,  &quot;abcd&quot;) -&gt; true  (wrong)
areAnagrams(&quot;abcd&quot;, &quot;abc&quot;)  -&gt; false (correct)

The problem is that you are checking that the characters in s1 exist with the same frequency in s2.  But there can be characters in s2 that do not exist in s1 and you don't check for those.
An easy way to remedy this would be to check that both strings have the same length.  This plus the frequency check you are already doing should ensure that the strings are anagrams.