A pointer expected error occurs when the compiler it gets to the assignment at the at end of the function. Why?
(Removed casts and index notation from code; they were there for "debugging" buy apparently cluttered my question.)
int createArraySimple(int initialResetCount, int ***array)
{
int sourceTermIndex, driveCurrentIndex, preEmphasisIndex, freqIndex, voltageIndex, slicerIndex, biasIndex;
int dataIndex, dataCount = 3;
*array = malloc(2*sizeof(int**)); // sourceTerm
if (*array == NULL)
return 0;
for (sourceTermIndex=0; sourceTermIndex < 2; sourceTermIndex++)
{
*((*array)+sourceTermIndex) = malloc(2*sizeof(int*)); // drive current
if (*((*array)+sourceTermIndex) == NULL)
return 0;
for (driveCurrentIndex=0; driveCurrentIndex < 2; driveCurrentIndex++)
{
*((*((*array)+sourceTermIndex))+driveCurrentIndex = malloc(2*sizeof(int)); // pre-emphasis
if (*((*((*array)+sourceTermIndex))+driveCurrentIndex) == NULL)
return 0;
}
}
//'initialize elements in array, since if they are not updated, we won't print them
for (sourceTermIndex = 0; sourceTermIndex < 2; sourceTermIndex++)
for (driveCurrentIndex = 0; driveCurrentIndex < 2; driveCurrentIndex++)
for (preEmphasisIndex = 0; preEmphasisIndex < 2; preEmphasisIndex++)
*((*((*((*array)+sourceTermIndex))+driveCurrentIndex))+preEmphasisIndex) = initialResetCount;
return 1;
}