I am trying to solve Hackerrank Find Digits problem and receiving this runtime error for questions involving arrays. I have tried freeing the array memory space but it's still the same. What changes do I make?
I tried declaring the arrays conventionally as well as by using malloc function.
#include <bits/stdc++.h>
using namespace std;
int main() {
int testCase,rem,count[]={0},n;
scanf("%d", &testCase);
int *numbers = (int*) malloc(testCase*sizeof(int));
for(int i=0; i<testCase; i++) 
    scanf("%d",numbers + i);
for(int i=0; i<testCase; i++) {
    n = *(numbers + i);
    while(n!=0) {
        int q = n % 10;      //get the units place
        rem = *(numbers + i) % q;         //find remainder
        if(rem == 0)
            count[i]++;
        n/=10;
    }
}
free(numbers);
for(int i=0; i<testCase; i++)
    printf("%d", count[i]);
free(count);
 return 0;
}
 
    