Okay, I'm writing a function where it's going to have to deal with three possible data types in an identical manner...
currently, I'll have to do the following
Code:
void *arrayPtr;
if(datatype == 1)
{
arrayPtr = calloc(5, sizeof(int));
int holder;
}
else if(datatype == 2)
{
arrayPtr = calloc(5, sizeof(double));
double holder;
}
else if(datatype == 3)
{
arrayPtr = calloc(5, sizeof(float));
float holder;
}
now, is it possible to create a function or macro that can let me replace the top with something like this?
Code:
void *arrayPtr;
arrayPtr = calloc(5, sizeof(TYPECONV(datatype)));
TYPECONV(datatype) holder;