anagram in c with runtime error
<p>Why do I get a runtime error? </p>

<p>Output Format</p>

<p>Print a single integer denoting the number of characters you must delete to make the two strings anagrams of each other.</p>

<p>We consider two strings to be anagrams of each other if the first string's letters can be rearranged to form the second string. In other words, both strings must contain the same exact letters in the same exact frequency</p>

<pre><code>#include &lt;math.h&gt;
#include &lt;stdio.h&gt;
#include &lt;string.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;assert.h&gt;
#include &lt;limits.h&gt;
#include &lt;stdbool.h&gt;


int cmpfunc (const void * a, const void * b){
   return ( *(int*)a - *(int*)b );
}

char* concat(const char *s1, const char *s2){

char *result = malloc(strlen(s1)+strlen(s2)+1);//+1 for the zero-terminator

strcpy(result, s1);
strcat(result, s2);
return result;
}

int main(){
char* a = (char *)malloc(512000 * sizeof(char));
scanf("%s",a);
char* b = (char *)malloc(512000 * sizeof(char));
scanf("%s",b);

int l1 = strlen(a);
int l2 = strlen(b);

if(l1 != l2){
    printf("String lengths do not match, exiting\n");
    exit(1);
}

char * s;
for (int i = 0; i &lt; l1; i++){
    s = concat(a, b);         
 }

qsort(s, l1, sizeof(int), cmpfunc);

int range[26]={0};

for(int i=0;i&lt;l1;i++){
    int t = s[i] - 'a';
    range[t]++;
}
int count = 0;
for(int i=0;i&lt;=l1;i++){
    count++;
}


printf("%d\n", count);



free(s);
free(a);
free(b);
return 0;
}
</code></pre>