I am attempting to pass a pointer to array in a function and return it back. The problem is that after correct initializing the function returns a NULL-pointer. Can anyone tell me, what is the issue with my logic?
Here is my function, where array is declared:
void main()
{
int errCode;
float *pol1, *pol2;
pol1 = pol2 = NULL;
errCode = inputPol("A", pol1);
if (errCode != 0)
{
return;
}
// using pol1 array
c = getchar();
}
And here is the function with initialization:
int inputPol(char* c, float *pol)
{
pol= (float *) calloc(13, sizeof( float ) );
while( TRUE )
{
// While smth happens
pol[i] = 42;
i++;
};
}
returnstatements. :-/callocin C