I have defined a struct as below
struct Invariant
{
int * numberOfConstPi; // Saves the number of constant Pi in each kernel
Invariant * next;
};
I then modified it later in the code as
invariant->numberOfConstPi = (int *)calloc(invariant->numberOfUniqueKernels, sizeof(int));
invariant->numberOfConstPi[countKernel] = numberOfConstPi;
Where countKernel is an iterator and numberOfConstPi is a variable.
Is this the correct way? When I run the code I'm getting segmentation errors.
But when I instead defined the array as
int * hello = (int *)calloc(invariant->numberOfUniqueKernels, sizeof(int));
and
hello[countKernel] = numberOfConstPi;
It works perfectly fine.
Kindly ignore the int variable numerOfUniqueKernels. It's just a number which I deleted from the Struct(to make the struct look simpler for the question)