I wanted to make a double array where the size will depends of the value enter by the user but when my double array is around [1999] I got segmentation fault.
So I decided to use pointers but here the problem, I set my value at 0 but after a few loop iterations, my value would change by itself.
Here is my code:
int Limit = 0;
int Bomb = 0;  
int getsum(int num)
{
    int result = 0;
    while (num)
    {
        result = result + num % 10;
        num /= 10;
    }
    return result;
}
int calc_limit(int x)
{
    while ((getsum(x)) < Bomb)
        x++;
    return x;
}
int main(int argc, char **argv)
{
    Bomb = atoi(argv[1]);
    Limit = calc_limit(0);
    int i = 0;
    int j = 0;
    bool **visited;                                                                                     
    if ((visited = malloc(Limit * sizeof(bool))) == NULL)
        return;
    while (i < Limit)
    {
        if ((visited[i] = malloc(Limit)) == NULL)
            return;
        while (j < Limit)
        {
            visited[i][j] = false;
            j++;
        }
        j = 0;
        i++;
    }
    //  printf("%d\n", visited[0][0]);                                                                                 
}
So for example, visited[0][0], is equal 0 when I set it but suddenly it will became equal 176.
I checked when this value change, and it change it change in my second loop when i = 3.
I have no idea why.
Thanks for your help
 
     
    