WA in KAN13C

Can u explain why this code is giving WA

include <stdio.h>
include <stdlib.h>
include <string.h>
int main() { char str = (char ) malloc(4 * 1000000 * sizeof(char)); int asv = (int ) malloc(4 * 1000000 * sizeof(int)); long long int i; long long int j; long long int k; long long int l;

while (1) {
scanf(“%s”, str);

   if (strcmp(str,"End") == 0)
        break;

   k = strlen(str);

   l = 0;

   for (i = 1; i < k; ++i) {
       if (str[i] == str[0])
           asv[i] = 1;
        else
            asv[i] = 0;
   }

   for (i = 1; i < k; ++i) {
         if (asv[i-1] >= 1 && asv[i-1] <= 9) {
            j = asv[i-1];
            if (str[i] == str[j]) {
               asv[i] = j + 1;
            }
         }
    }

   for (i = 0; i < k; ++i)
       printf("%d ", asv[i]);

   printf("\n");

}

free(asv);
free(str);
return 0;
} It is working fine for all cases in my system. Ideone link is :-- vV6bYl - Online C Compiler & Debugging Tool - Ideone.com Thnx in advance

ur code fails on the input string containing word length greater than 10 .

ur code fails on this input

bbaabaaaaabbbbbbbaba
bbaabaaaaabbbbbbbababbaabaaaaabbbbbbbaba
End

expected output is

0 1 0 0 1 0 0 0 0 0 1 2 2 2 2 2 2 3 1 0 
0 1 0 0 1 0 0 0 0 0 1 2 2 2 2 2 2 3 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 

and ur code gives

0 1 0 0 1 0 0 0 0 0 1 2 1 2 1 2 1 0 1 0 
0 1 0 0 1 0 0 0 0 0 1 2 1 2 1 2 1 0 1 0 1 2 3 4 5 6 7 8 9 10 1 2 1 2 1 2 1 0 1 0