Count of anagrams of a text in a given string
You code is quite efficient and well designed. I think you can get a little bit more efficiency at the cost of making the code more specific to this particular task. In particular there are some shortcuts:


your pattern is always the same so you could cache the computation of the array b[26]. This would double the speed
when you fill array a[] you could stop whenever a[i]&gt;b[i]. This could speed up your algorithm a lot in some scenarios. For example you skip a position at once if the letter in the text is not in the pattern.
you are making copies of strings just to add the null terminator. You can avoid this by adding the length of the string as a parameter to your first function. This would help point 2 to be quite fast in the scenario already mentioned.
you can update the array a[26] incrementally. You decrease the count of character which exit the window and increment the count of characters entering it. 


Putting all together (not tested):

int check(const char *text, const char *pattern) {
    int pattern_frequency[26];
    int text_frequency[26];
    int matches = 0;
    int pattern_length;
    for (int i=0; i&lt;26; ++i) {
        pattern_frequency[i] = 0;
        text_frequency[i] = 0;
    }
    for (pattern_length=0; pattern[pattern_length]; ++pattern_length) {
       int i = pattern[pattern_length]-'a';
       assert(i&gt;=0 &amp;&amp; i&lt;26);
       pattern_frequency[i]++;   
    }
    for (int i=0; text[i]; ++i) {
        if (i&gt;=pattern_length) {
            text_frequency[text[i-pattern_length]-'a']--;
        }
        int c = text[i]-'a';
        assert(c&gt;=0 &amp;&amp; c&lt;26);
        text_frequency[c]++;
        if (text_frequency[c] != pattern_frequency[c]) continue; // shortcut
        int j;
        for (j=0;j&lt;26 &amp;&amp; text_frequency[j]==pattern_frequency[j];++j);
        if (j&lt;26) continue;
        matches ++;
    } 
    return matches;
}


If n is the length of the text and m the length of the pattern, your algorithm is O(nm) while this one is O(n+m) which cannot be improved further.